Skip to content

Commit

Permalink
use around instead of SUPER for BUILDARGS
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanez committed Feb 21, 2013
1 parent d678de8 commit 30f76cc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/Throwable/Error.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 30f76cc

Please sign in to comment.