From: Stevan Little Date: Tue, 28 Feb 2006 19:30:31 +0000 (+0000) Subject: preserving call context X-Git-Tag: 0_20~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bfc88f317e95e6dae98043545889a6e2f3e0c98b;p=gitmo%2FClass-MOP.git preserving call context --- diff --git a/lib/Class/MOP/Method.pm b/lib/Class/MOP/Method.pm index 4de0cdf..912368a 100644 --- a/lib/Class/MOP/Method.pm +++ b/lib/Class/MOP/Method.pm @@ -45,16 +45,21 @@ sub new { }; my $method = $code->new(sub { $_->(@_) for @{$modifier_table->{before}}; - my @rval; + my (@rlist, $rval); if (defined wantarray) { - @rval = $modifier_table->{around}->{cache}->(@_); + if (wantarray) { + @rlist = $modifier_table->{around}->{cache}->(@_); + } + else { + $rval = $modifier_table->{around}->{cache}->(@_); + } } else { $modifier_table->{around}->{cache}->(@_); } $_->(@_) for @{$modifier_table->{after}}; return unless defined wantarray; - return wantarray ? @rval : $rval[0]; + return wantarray ? @rlist : $rval; }); $MODIFIERS{$method} = $modifier_table; $method;