Make chaining to yourself explode at app load time + tests from bug ash found, remove...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Chained.pm
index a27f6ba..95d6559 100644 (file)
@@ -5,6 +5,7 @@ extends 'Catalyst::DispatchType';
 
 use Text::SimpleTable;
 use Catalyst::ActionChain;
+use Catalyst::Utils;
 use URI;
 
 has _endpoints => (
@@ -67,9 +68,10 @@ sub list {
 
     return unless $self->_endpoints;
 
+    my $column_width = Catalyst::Utils::term_width() - 35 - 9;
     my $paths = Text::SimpleTable->new(
-                    [ 35, 'Path Spec' ], [ 36, 'Private' ]
-                );
+       [ 35, 'Path Spec' ], [ $column_width, 'Private' ],
+    );
 
     my $has_unattached_actions;
     my $unattached_actions = Text::SimpleTable->new(
@@ -256,8 +258,13 @@ sub register {
           "Multiple Chained attributes not supported registering ${action}"
         );
     }
+    my $chained_to = $chained_attr[0];
 
-    my $children = ($self->_children_of->{ $chained_attr[0] } ||= {});
+    Catalyst::Exception->throw(
+      "Actions cannot chain to themselves registering /${action}"
+    ) if ($chained_to eq '/' . $action);
+
+    my $children = ($self->_children_of->{ $chained_to } ||= {});
 
     my @path_part = @{ $action->attributes->{PathPart} || [] };
 
@@ -330,6 +337,14 @@ sub uri_for_action {
    
 }
 
+=head2 $c->expand_action($action)
+
+Return a list of actions that represents a chained action. See 
+L<Catalyst::Dispatcher> for more info. You probably want to
+use the expand_action it provides rather than this directly.
+
+=cut
+
 sub expand_action {
     my ($self, $action) = @_;