From: Matt S Trout Date: Thu, 22 Jun 2006 14:52:46 +0000 (+0000) Subject: added :Chained('.'), changed :Chained to / X-Git-Tag: 5.7099_04~483 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=1dc8af447f43168c875c0c62f2cfb50d66173eaf added :Chained('.'), changed :Chained to / r10075@cain (orig r4405): matthewt | 2006-06-18 16:57:55 +0000 --- diff --git a/lib/Catalyst/DispatchType/Chained.pm b/lib/Catalyst/DispatchType/Chained.pm index 132d9ef..52ba7c9 100644 --- a/lib/Catalyst/DispatchType/Chained.pm +++ b/lib/Catalyst/DispatchType/Chained.pm @@ -163,24 +163,26 @@ Matt is an idiot and hasn't documented this yet. sub register { my ( $self, $c, $action ) = @_; - my @child_of_attr = @{ $action->attributes->{Chained} || [] }; + my @chained_attr = @{ $action->attributes->{Chained} || [] }; - return 0 unless @child_of_attr; + return 0 unless @chained_attr; - if (@child_of_attr > 2) { + if (@chained_attr > 2) { Catalyst::Exception->throw( "Multiple Chained attributes not supported registering ${action}" ); } - my $parent = $child_of_attr[0]; + my $parent = $chained_attr[0]; if (defined($parent) && length($parent)) { - unless ($parent =~ m/^\//) { + if ($parent eq '.') { + $parent = '/'.$action->namespace; + } elsif ($parent !~ m/^\//) { $parent = '/'.join('/', $action->namespace, $parent); } } else { - $parent = '/'.$action->namespace; + $parent = '/' } $action->attributes->{Chained} = [ $parent ]; diff --git a/t/lib/TestApp/Controller/Action/Chained/Foo.pm b/t/lib/TestApp/Controller/Action/Chained/Foo.pm index 2ebd39d..4ff9b20 100644 --- a/t/lib/TestApp/Controller/Action/Chained/Foo.pm +++ b/t/lib/TestApp/Controller/Action/Chained/Foo.pm @@ -8,7 +8,7 @@ use base qw/Catalyst::Controller/; # # Child of current namespace # -sub spoon :Chained('') :Args(0) { } +sub spoon :Chained('.') :Args(0) { } # # Root for a action in a "parent" controller