From 30f76cc1588866490ca3dd5bd16380df49fab043 Mon Sep 17 00:00:00 2001 From: Justin Hunter Date: Thu, 21 Feb 2013 16:34:56 -0500 Subject: [PATCH] use around instead of SUPER for BUILDARGS --- lib/Throwable/Error.pm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/Throwable/Error.pm b/lib/Throwable/Error.pm index a1f739c..41e4a6f 100644 --- a/lib/Throwable/Error.pm +++ b/lib/Throwable/Error.pm @@ -82,17 +82,18 @@ sub as_string { return $str; } -sub BUILDARGS { - my ($self, @args) = @_; +around BUILDARGS => sub { + my $orig = shift; + my $self = shift; - return {} unless @args; - return {} if @args == 1 and ! defined $args[0]; + return {} unless @_; + return {} if @_ == 1 and ! defined $_[0]; - if (@args == 1 and (!ref $args[0]) and defined $args[0] and length $args[0]) { - return { message => $args[0] }; + if (@_ == 1 and (!ref $_[0]) and defined $_[0] and length $_[0]) { + return { message => $_[0] }; } - return $self->SUPER::BUILDARGS(@args); -} + return $self->$orig(@_); +}; 1;