X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;h=c03f1b33822d64f55324f35c5f7b251048017188;hp=391fefcc25c34c0e0bb3666e13c3425942f2d9e6;hb=b8f669f3c51dab87bfe9387dbaac0c07027abcfd;hpb=e540158b361fd2c610c58fec1ee2608cfba61e51 diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 391fefc..c03f1b3 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -159,7 +159,7 @@ sub forward { #push @$args, @_; local $c->request->{arguments} = $args; - $action->execute($c); + $action->dispatch( $c ); return $c->state; } @@ -286,12 +286,24 @@ returns a named action from a given namespace. sub get_action { my ( $self, $name, $namespace ) = @_; return unless $name; - $namespace ||= ''; - $namespace = '' if $namespace eq '/'; + + $namespace = join( "/", grep { length } split '/', $namespace || "" ); return $self->action_hash->{"$namespace/$name"}; } +=head2 $self->get_action_by_path( $path ); + +Returns the named action by its full path. + +=cut + +sub get_action_by_path { + my ( $self, $path ) = @_; + $path = "/$path" unless $path =~ /\//; + $self->action_hash->{$path}; +} + =head2 $self->get_actions( $c, $action, $namespace ) =cut @@ -299,8 +311,8 @@ sub get_action { sub get_actions { my ( $self, $c, $action, $namespace ) = @_; return [] unless $action; - $namespace ||= ''; - $namespace = '' if $namespace eq '/'; + + $namespace = join( "/", grep { length } split '/', $namespace || "" ); my @match = $self->get_containers($namespace); @@ -320,9 +332,11 @@ sub get_containers { my @containers; - do { - push @containers, $self->container_hash->{$namespace}; - } while ( $namespace =~ s#/[^/]+$## ); + if ( length $namespace ) { + do { + push @containers, $self->container_hash->{$namespace}; + } while ( $namespace =~ s#/[^/]+$## ); + } return reverse grep { defined } @containers, $self->container_hash->{''}; @@ -428,7 +442,7 @@ sub setup_actions { my $privates = Text::SimpleTable->new( [ 20, 'Private' ], - [ 38, 'Class' ], + [ 36, 'Class' ], [ 12, 'Method' ] );