X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FAction.pm;h=ec30c7ab50522295de95fb17d405f32d961a8158;hp=5ee38e9ef6f09ac11a3836d1ddbfe55948234e44;hb=c1192f1ed63f124eb2d143e10b215703e7dc6284;hpb=aef0cb5dc1b5dbadba8f6345587ea2012011108f diff --git a/lib/Catalyst/Action.pm b/lib/Catalyst/Action.pm index 5ee38e9..ec30c7a 100644 --- a/lib/Catalyst/Action.pm +++ b/lib/Catalyst/Action.pm @@ -271,8 +271,12 @@ sub execute { sub match { my ( $self, $c ) = @_; + return $self->match_args($c, $c->req->args); +} - warn $self->reverse; +sub match_args { + my ($self, $c, $args) = @_; + my @args = @{$args||[]}; # If infinite args, we always match return 1 if $self->normalized_arg_number == ~0; @@ -289,7 +293,7 @@ sub match { $self->args_constraints->[0]->is_a_type_of('ClassName') ) ) { - return $self->args_constraints->[0]->check($c->req->args); + return $self->args_constraints->[0]->check($args); # Removing coercion stuff for the first go #if($self->args_constraints->[0]->coercion && $self->attributes->{Coerce}) { # my $coerced = $self->args_constraints->[0]->coerce($c) || return 0; @@ -299,16 +303,16 @@ sub match { } else { # Because of the way chaining works, we can expect args that are totally not # what you'd expect length wise. When they don't match length, thats a fail - return 0 unless scalar( @{ $c->req->args } ) == $self->normalized_arg_number; + return 0 unless scalar( @args ) == $self->normalized_arg_number; - for my $i(0..$#{ $c->req->args }) { - $self->args_constraints->[$i]->check($c->req->args->[$i]) || return 0; + for my $i(0..$#args) { + $self->args_constraints->[$i]->check($args[$i]) || return 0; } return 1; } } else { # Otherwise, we just need to match the number of args. - return scalar( @{ $c->req->args } ) == $self->normalized_arg_number; + return scalar( @args ) == $self->normalized_arg_number; } } @@ -402,6 +406,11 @@ of the captures for this action. Returning true from this method causes the chain match to continue, returning makes the chain not match (and alternate, less preferred chains will be attempted). +=head2 match_args($c, $args) + +Underlying feature that does the 'match' work, but doesn't require a context to +work (like 'match' does.). + =head2 resolve_type_constraint Trys to find a type constraint if you have on on a type constrained method.