X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;fp=lib%2FCatalyst%2FDispatcher.pm;h=4029ec37f14e06e250a35e573fc0d291208d5581;hb=21c94d83082b43028cafcfb18659090b13d832fa;hp=d82dfe18f9552f1feea4aa28e68eb4c176379e59;hpb=30fe793be0d7595dcd1b888ef281c03864f6cd1d;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index d82dfe1..4029ec3 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -497,6 +497,31 @@ sub expand_action { return $action; } +=head2 $self->splice_captures_from( $c, $action, $args ) + +Does nothing if the first element of the list that C<$args> references +is an array ref. Otherwise calls this method in each dispatch type, +stopping when the first one returns true + +=cut + +sub splice_captures_from { + my ($self, $c, $action, $args) = @_; + + return if (!$args || (scalar @{ $args } && ref $args->[0] eq 'ARRAY')); + + my $params = scalar @{ $args } && ref $args->[-1] eq 'HASH' + ? pop @{ $args } : undef; + + foreach my $dispatch_type ( @{ $self->dispatch_types } ) { + last if ($dispatch_type->splice_captures_from( $c, $action, $args )); + } + + push @{ $args }, $params if ($params); # Restore query parameters + + return; +} + =head2 $self->register( $c, $action ) Make sure all required dispatch types for this action are loaded, then