X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FDispatchType%2FChained.pm;h=44f890e59037d5f4e35b958169514a46d66070c1;hp=2b27ec49eebb9d57e12b11a937482e41ae94977e;hb=87106f31bcbbacc350449a6fbe5d6de50b876057;hpb=6a61d5b76357261fef77fc2151899491f2ec4695 diff --git a/lib/Catalyst/DispatchType/Chained.pm b/lib/Catalyst/DispatchType/Chained.pm index 2b27ec4..44f890e 100644 --- a/lib/Catalyst/DispatchType/Chained.pm +++ b/lib/Catalyst/DispatchType/Chained.pm @@ -100,6 +100,7 @@ sub list { my @parts = (defined($args) ? (("*") x $args) : '...'); my @parents = (); my $parent = "DUMMY"; + my $extra = $self->_list_extra_http_methods($endpoint); my $curr = $endpoint; while ($curr) { if (my $cap = $curr->list_extra_info->{CaptureArgs}) { @@ -121,18 +122,19 @@ sub list { my @rows; foreach my $p (@parents) { my $name = "/${p}"; + + if (defined(my $extra = $self->_list_extra_http_methods($p))) { + $name = "${extra} ${name}"; + } if (defined(my $cap = $p->list_extra_info->{CaptureArgs})) { $name .= ' ('.$cap.')'; } unless ($p eq $parents[0]) { $name = "-> ${name}"; } - if (defined(my $extra = $p->list_extra_info->{HTTP_METHODS})) { - $name .= ' ('.join(', ', @$extra).')'; - } push(@rows, [ '', $name ]); } - push(@rows, [ '', (@rows ? "=> " : '')."/${endpoint}" ]); + push(@rows, [ '', (@rows ? "=> " : '').($extra ? "$extra " : '')."/${endpoint}" ]); $rows[0][0] = join('/', '', @parts) || '/'; $paths->row(@$_) for @rows; } @@ -142,6 +144,12 @@ sub list { if $has_unattached_actions; } +sub _list_extra_http_methods { + my ( $self, $action ) = @_; + return unless defined $action->list_extra_info->{HTTP_METHODS}; + return join(', ', @{$action->list_extra_info->{HTTP_METHODS}}); +} + =head2 $self->match( $c, $path ) Calls C to see if a chain matches the C<$path>. @@ -204,16 +212,16 @@ sub recurse_match { my @try_actions = @{$children->{$try_part}}; TRY_ACTION: foreach my $action (@try_actions) { if (my $capture_attr = $action->attributes->{CaptureArgs}) { - $capture_attr ||= 0; + my $capture_count = $capture_attr->[0] || 0; # Short-circuit if not enough remaining parts - next TRY_ACTION unless @parts >= $capture_attr->[0]; + next TRY_ACTION unless @parts >= $capture_count; my @captures; my @parts = @parts; # localise # strip CaptureArgs into list - push(@captures, splice(@parts, 0, $capture_attr->[0])); + push(@captures, splice(@parts, 0, $capture_count)); # check if the action may fit, depending on a given test by the app if ($action->can('match_captures')) { next TRY_ACTION unless $action->match_captures($c, \@captures) } @@ -333,7 +341,7 @@ sub register { $args = Data::Dumper::Dumper($args); Catalyst::Exception->throw( "Invalid Args($args) for action " . $action->reverse() . - " (use 'Args' or 'Args()'" + " (use 'Args' or 'Args()')" ); } } @@ -677,9 +685,11 @@ of the endpoint of the chain, not on the chained actions way. The C actions will be run before the chain dispatching begins. In every other aspect, C actions behave as documented. -The Cing to other actions does just what you would expect. But if -you C out of a chain, the rest of the chain will not get called -after the C. +The Cing to other actions does just what you would expect. i.e. +only the target action is run. The actions that that action is chained +to are not run. +If you C out of a chain, the rest of the chain will not get +called after the C. =head2 match_captures