X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatchType%2FPath.pm;h=ccff553d4a74ee0423bd9c4bd7a910471c29b8b9;hb=694d15f1f6031de10d1ecb047b9e66dd0982e3a3;hp=31f37b3e9790d5367aeb087c847c529d4edc8397;hpb=8c11318848e17f92027484614d393b6ebd365f7d;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index 31f37b3..ccff553 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -62,7 +62,10 @@ sub register { my @register; foreach my $r ( @{ $attrs->{Path} || [] } ) { - unless ( $r =~ m!^/! ) { # It's a relative path + unless ($r) { + $r = $action->namespace; + } + elsif ( $r !~ m!^/! ) { # It's a relative path $r = $action->namespace . "/$r"; } push( @register, $r ); @@ -78,10 +81,19 @@ sub register { # Register sub name as a relative path } - foreach my $r (@register) { - $r =~ s!^/!!; - $self->{paths}{$r} = $action; - } + $self->register_path( $c, $_, $action ) for @register; + return 1 if @register; + return 0; +} + +=item $self->register_path($c, $path, $action) + +=cut + +sub register_path { + my ( $self, $c, $path, $action ) = @_; + $path =~ s!^/!!; + $self->{paths}{$path} = $action; } =back