reverting back to when tests pass. applying changes one by one to find what failed
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Chained.pm
index bc12721..0dc4c25 100644 (file)
@@ -1,33 +1,14 @@
 package Catalyst::DispatchType::Chained;
 
 use Moose;
+extends 'Catalyst::DispatchType';
+
+#use strict;
+#use base qw/Catalyst::DispatchType/;
 use Text::SimpleTable;
 use Catalyst::ActionChain;
 use URI;
 
-extends 'Catalyst::DispatchType';
-
-has _endpoints => (
-                   isa => 'rw',
-                   isa => 'ArrayRef',
-                   required => 1,
-                   default => sub{ [] },
-                  );
-
-has _actions => (
-                 isa => 'rw',
-                 isa => 'HashRef',
-                 required => 1,
-                 default => sub{ {} },
-                );
-
-has _children_of => (
-                     isa => 'rw',
-                     isa => 'HashRef',
-                     required => 1,
-                     default => sub{ {} },
-                    );
-
 # please don't perltidy this. hairy code within.
 
 =head1 NAME
@@ -63,7 +44,7 @@ Debug output for Path Part dispatch points
 sub list {
     my ( $self, $c ) = @_;
 
-    return unless $self->_endpoints;
+    return unless $self->{endpoints};
 
     my $paths = Text::SimpleTable->new(
                     [ 35, 'Path Spec' ], [ 36, 'Private' ]
@@ -71,7 +52,7 @@ sub list {
 
     ENDPOINT: foreach my $endpoint (
                   sort { $a->reverse cmp $b->reverse }
-                           @{ $self->_endpoints }
+                           @{ $self->{endpoints} }
                   ) {
         my $args = $endpoint->attributes->{Args}->[0];
         my @parts = (defined($args) ? (("*") x $args) : '...');
@@ -87,7 +68,7 @@ sub list {
                     if (defined $pp->[0] && length $pp->[0]);
             }
             $parent = $curr->attributes->{Chained}->[0];
-            $curr = $self->_actions->{$parent};
+            $curr = $self->{actions}{$parent};
             unshift(@parents, $curr) if $curr;
         }
         next ENDPOINT unless $parent eq '/'; # skip dangling action
@@ -147,7 +128,7 @@ Recursive search for a matching chain.
 
 sub recurse_match {
     my ( $self, $c, $parent, $path_parts ) = @_;
-    my $children = $self->_children_of->{$parent};
+    my $children = $self->{children_of}{$parent};
     return () unless $children;
     my $best_action;
     my @captures;
@@ -254,7 +235,7 @@ sub register {
 
     $action->attributes->{Chained} = [ $parent ];
 
-    my $children = $self->_children_of->{$parent};
+    my $children = ($self->{children_of}{$parent} ||= {});
 
     my @path_part = @{ $action->attributes->{PathPart} || [] };
 
@@ -278,10 +259,10 @@ sub register {
 
     unshift(@{ $children->{$part} ||= [] }, $action);
 
-    $self->_actions->{'/'.$action->reverse} = $action;
+    ($self->{actions} ||= {})->{'/'.$action->reverse} = $action;
 
     unless ($action->attributes->{CaptureArgs}) {
-        unshift(@{ $self->_endpoints }, $action);
+        unshift(@{ $self->{endpoints} ||= [] }, $action);
     }
 
     return 1;
@@ -316,7 +297,7 @@ sub uri_for_action {
                 if (defined($pp->[0]) && length($pp->[0]));
         }
         $parent = $curr->attributes->{Chained}->[0];
-        $curr = $self->_actions->{$parent};
+        $curr = $self->{actions}{$parent};
     }
 
     return undef unless $parent eq '/'; # fail for dangling action