tweaked ChildOf debug output
Matt S Trout [Thu, 22 Jun 2006 14:51:25 +0000 (14:51 +0000)]
r10054@cain (orig r4391):  matthewt | 2006-06-17 15:50:43 +0000

lib/Catalyst/DispatchType/ChildOf.pm

index 1719483..9b58d85 100644 (file)
@@ -41,6 +41,7 @@ sub list {
                   ) {
         my $args = $endpoint->attributes->{Args}->[0];
         my @parts = (defined($args) ? (("*") x $args) : '...');
+        my @parents = ();
         my $parent = "DUMMY";
         my $curr = $endpoint;
         while ($curr) {
@@ -53,9 +54,23 @@ sub list {
             }
             $parent = $curr->attributes->{ChildOf}->[0];
             $curr = $self->{actions}{$parent};
+            unshift(@parents, $curr) if $curr;
         }
         next ENDPOINT unless $parent eq '/'; # skip dangling action
-        $paths->row(join('/', '', @parts), "/$endpoint");
+        my @rows;
+        foreach my $p (@parents) {
+            my $name = "/${p}";
+            if (my $cap = $p->attributes->{Captures}) {
+                $name .= ' ('.$cap->[0].')';
+            }
+            unless ($p eq $parents[0]) {
+                $name = "-> ${name}";
+            }
+            push(@rows, [ '', $name ]);
+        }
+        push(@rows, [ '', (@rows ? "=> " : '')."/${endpoint}" ]);
+        $rows[0][0] = join('/', '', @parts);
+        $paths->row(@$_) for @rows;
     }
 
     $c->log->debug( "Loaded Path Part actions:\n" . $paths->draw );