From: Florian Ragwitz Date: Sun, 24 Aug 2008 19:31:44 +0000 (+0000) Subject: Move :Chained sugar out of DispatchType::Chained. X-Git-Tag: 5.7099_04~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=f3107403051db906860025158685191ad7fad0fe Move :Chained sugar out of DispatchType::Chained. --- diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index b235774..657c59e 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -279,6 +279,28 @@ sub _parse_LocalRegex_attr { sub _parse_LocalRegexp_attr { shift->_parse_LocalRegex_attr(@_); } +sub _parse_Chained_attr { + my ($self, $c, $name, $value) = @_; + + if (defined($value) && length($value)) { + if ($value eq '.') { + $value = '/'.$self->action_namespace($c); + } elsif ($value !~ m/^\//) { + my $action_ns = $self->action_namespace($c); + + if ($action_ns) { + $value = '/'.join('/', $action_ns, $value); + } else { + $value = '/'.$value; # special case namespace '' (root) + } + } + } else { + $value = '/' + } + + return Chained => $value; +} + sub _parse_PathPrefix_attr { my $self = shift; return PathPart => $self->path_prefix; diff --git a/lib/Catalyst/DispatchType/Chained.pm b/lib/Catalyst/DispatchType/Chained.pm index 71fec41..7d0bbc9 100644 --- a/lib/Catalyst/DispatchType/Chained.pm +++ b/lib/Catalyst/DispatchType/Chained.pm @@ -221,25 +221,7 @@ sub register { ); } - my $parent = $chained_attr[0]; - - if (defined($parent) && length($parent)) { - if ($parent eq '.') { - $parent = '/'.$action->namespace; - } elsif ($parent !~ m/^\//) { - if ($action->namespace) { - $parent = '/'.join('/', $action->namespace, $parent); - } else { - $parent = '/'.$parent; # special case namespace '' (root) - } - } - } else { - $parent = '/' - } - - $action->attributes->{Chained} = [ $parent ]; - - my $children = ($self->{children_of}{$parent} ||= {}); + my $children = ($self->{children_of}{ $chained_attr[0] } ||= {}); my @path_part = @{ $action->attributes->{PathPart} || [] };