added :Chained('.'), changed :Chained to /
Matt S Trout [Thu, 22 Jun 2006 14:52:46 +0000 (14:52 +0000)]
r10075@cain (orig r4405):  matthewt | 2006-06-18 16:57:55 +0000

lib/Catalyst/DispatchType/Chained.pm
t/lib/TestApp/Controller/Action/Chained/Foo.pm

index 132d9ef..52ba7c9 100644 (file)
@@ -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 ];
index 2ebd39d..4ff9b20 100644 (file)
@@ -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