preserving call context
Stevan Little [Tue, 28 Feb 2006 19:29:27 +0000 (19:29 +0000)]
lib/Class/MOP/Method.pm

index 912368a..4de0cdf 100644 (file)
@@ -45,21 +45,16 @@ sub new {
                };
                my $method = $code->new(sub {
                        $_->(@_) for @{$modifier_table->{before}};
-                       my (@rlist, $rval);
+                       my @rval;
                        if (defined wantarray) {
-                               if (wantarray) {
-                                       @rlist = $modifier_table->{around}->{cache}->(@_);
-                               }
-                               else {
-                                       $rval = $modifier_table->{around}->{cache}->(@_);
-                               }
+                               @rval = $modifier_table->{around}->{cache}->(@_);
                        }
                        else {
                                $modifier_table->{around}->{cache}->(@_);
                        }
                        $_->(@_) for @{$modifier_table->{after}};                       
                        return unless defined wantarray;
-                       return wantarray ? @rlist : $rval;
+                       return wantarray ? @rval : $rval[0];
                });     
                $MODIFIERS{$method} = $modifier_table;
                $method;