From: Christian Hansen Date: Fri, 24 Jun 2005 13:56:05 +0000 (+0000) Subject: refactored $c->forward X-Git-Tag: 5.7099_04~1287 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=e0fc6749d93c698e47b95bf18f143333d2845332 refactored $c->forward --- diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index af4f7ce..19c844d 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -104,7 +104,7 @@ sub dispatch { } } -=item $c->forward($command [args])) +=item $c->forward( $command [, \@arguments ] ) Forward processing to a private action or a method from a class. If you define a class without method it will default to process(). @@ -130,15 +130,7 @@ sub forward { my $caller = caller(0); my $namespace = '/'; - my $args; - - if ( ref( $_[0] ) eq 'ARRAY' ) { - $args=$c->req->args(); - $c->req->args( shift ); - } elsif ( ref( $_[1] ) eq 'ARRAY' ) { - $args=$c->req->args(); - $c->req->args( $_[1] ); - } + my $arguments = ( ref( $_[-1] ) eq 'ARRAY' ) ? pop(@_) : $c->req->args; if ( $command =~ /^\// ) { $command =~ /^\/(.*)\/(\w+)$/; @@ -193,15 +185,15 @@ sub forward { } } + + local $c->request->{arguments} = $arguments; for my $result ( @{$results} ) { $c->execute( @{ $result->[0] } ); - last if scalar @{ $c->error }; + return if scalar @{ $c->error }; last unless $c->state; } - $c->req->args( $args ) if $args; - return if scalar @{ $c->error }; return $c->state; }