From: Matt S Trout Date: Thu, 22 Jun 2006 14:51:58 +0000 (+0000) Subject: no :PathPart -> :PathPart('subname') X-Git-Tag: 5.7099_04~490 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=09461385e3f0f62cbf3a95a71d00f71e1a42ca75;hp=7a7ac23cbfaba1c66a454132313ceb7e885ab98b no :PathPart -> :PathPart('subname') r10066@cain (orig r4397): matthewt | 2006-06-17 20:48:29 +0000 --- diff --git a/lib/Catalyst/DispatchType/ChildOf.pm b/lib/Catalyst/DispatchType/ChildOf.pm index f54e322..2ab537e 100644 --- a/lib/Catalyst/DispatchType/ChildOf.pm +++ b/lib/Catalyst/DispatchType/ChildOf.pm @@ -189,10 +189,10 @@ sub register { my @path_part = @{ $action->attributes->{PathPart} || [] }; - my $part = ''; + my $part = $action->name; - if (@path_part == 1) { - $part = (defined $path_part[0] ? $path_part[0] : $action->name); + if (@path_part == 1 && defined $path_part[0]) { + $part = $path_part[0]; } elsif (@path_part > 1) { Catalyst::Exception->throw( "Multiple PathPart attributes not supported registering ${action}" diff --git a/t/lib/TestApp/Controller/Action/ChildOf.pm b/t/lib/TestApp/Controller/Action/ChildOf.pm index a244a98..ba6e5d2 100644 --- a/t/lib/TestApp/Controller/Action/ChildOf.pm +++ b/t/lib/TestApp/Controller/Action/ChildOf.pm @@ -23,7 +23,7 @@ sub endpoint2 :PathPart('end2') :ChildOf('/action/childof/foo2') :Args(2) { } # Relative specification of parent action # sub bar :PathPart('childof/bar') :ChildOf('/') :Captures(0) { } -sub finale :ChildOf('bar') :Args { } +sub finale :PathPart('') :ChildOf('bar') :Args { } # # three chain with concurrent endpoints @@ -49,7 +49,7 @@ sub higher_root :PathPart('bar') :ChildOf('/action/childof/foo/higher_root') :Ar # Controller -> subcontroller -> controller # sub pcp1 :PathPart('childof/pcp1') :ChildOf('/') :Captures(1) { } -sub pcp3 :PathPart :ChildOf('/action/childof/foo/pcp2') :Args(1) { } +sub pcp3 :ChildOf('/action/childof/foo/pcp2') :Args(1) { } # # Dispatch on capture number diff --git a/t/lib/TestApp/Controller/Action/ChildOf/Foo.pm b/t/lib/TestApp/Controller/Action/ChildOf/Foo.pm index 1e1ea0a..d75f45a 100644 --- a/t/lib/TestApp/Controller/Action/ChildOf/Foo.pm +++ b/t/lib/TestApp/Controller/Action/ChildOf/Foo.pm @@ -8,7 +8,7 @@ use base qw/Catalyst::Controller/; # # Child of current namespace # -sub spoon :PathPart :ChildOf('') :Args(0) { } +sub spoon :ChildOf('') :Args(0) { } # # Root for a action in a "parent" controller @@ -18,7 +18,7 @@ sub higher_root :PathPart('childof/higher_root') :ChildOf('/') :Captures(1) { } # # Parent controller -> this subcontroller -> parent controller test # -sub pcp2 :PathPart :ChildOf('/action/childof/pcp1') :Captures(1) { } +sub pcp2 :ChildOf('/action/childof/pcp1') :Captures(1) { } # # Controllers not in parent/child relation. This tests the end.