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=32d9b99f9096f19f099771762f64ea8d8764b975;hp=0a38d75b4f8472af577e31d8031657ed98ba4166;hb=ec4d72594fb7a701c2f36e85ecf9a680ca1abba2;hpb=d9f0a350554cca79adefd4e97b4982d431f8c914 diff --git a/lib/Catalyst/Action.pm b/lib/Catalyst/Action.pm index 0a38d75..32d9b99 100644 --- a/lib/Catalyst/Action.pm +++ b/lib/Catalyst/Action.pm @@ -371,28 +371,37 @@ sub match_captures { my @captures = @{$captures||[]}; return 1 unless scalar(@captures); # If none, just say its ok + return $self->has_captures_constraints ? + $self->match_captures_constraints($c, $captures) : 1; - if($self->has_captures_constraints) { - if( - $self->captures_constraints_count == 1 && - ( - $self->captures_constraints->[0]->is_a_type_of('Ref') || - $self->captures_constraints->[0]->is_a_type_of('ClassName') - ) - ) { - return $self->captures_constraints->[0]->check($captures); - } else { - for my $i(0..$#captures) { - $self->captures_constraints->[$i]->check($captures[$i]) || return 0; - } - return 1; - } + return 1; +} + +sub match_captures_constraints { + my ($self, $c, $captures) = @_; + my @captures = @{$captures||[]}; + + # Match is positive if you don't have any. + return 1 unless $self->has_captures_constraints; + + if( + $self->captures_constraints_count == 1 && + ( + $self->captures_constraints->[0]->is_a_type_of('Ref') || + $self->captures_constraints->[0]->is_a_type_of('ClassName') + ) + ) { + return $self->captures_constraints->[0]->check($captures); } else { + for my $i(0..$#captures) { + $self->captures_constraints->[$i]->check($captures[$i]) || return 0; + } return 1; - } - return 1; + } + } + sub compare { my ($a1, $a2) = @_; return $a1->normalized_arg_number <=> $a2->normalized_arg_number; @@ -456,6 +465,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_captures_constraints ($c, \@captures); + +Does the \@captures given match any constraints (if any constraints exist). Returns +true if you ask but there are no constraints. + =head2 match_args($c, $args) Does the Args match or not?