X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FActionContainer.pm;h=848f71aa21a63cb90167e74ee3879434cc9e8e5a;hb=b354201608d428db344c63dd35de096a62a7a9d3;hp=2f98be169cfa466be5b06043eabc2f89897fb7fe;hpb=b8ea7be4b18e77f8f3a094d5af64b9e3152ab6d3;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/ActionContainer.pm b/lib/Catalyst/ActionContainer.pm index 2f98be1..848f71a 100644 --- a/lib/Catalyst/ActionContainer.pm +++ b/lib/Catalyst/ActionContainer.pm @@ -16,17 +16,24 @@ to represent the various dispatch points in your application. =cut use Moose; +with 'MooseX::Emulate::Class::Accessor::Fast'; has part => (is => 'rw', required => 1); has actions => (is => 'rw', required => 1, lazy => 1, default => sub { {} }); -around new => sub { - my ($orig, $self, $params) = @_; - $orig->($self, (ref($params) ? $params : { part => $params } )); +around BUILDARGS => sub { + my ($next, $self, @args) = @_; + unshift @args, 'part' if scalar @args == 1 && !ref $args[0]; + return $self->$next(@args); }; no Moose; +use overload ( + # Stringify to path part for tree search + q{""} => sub { shift->part }, +); + sub get_action { my ( $self, $name ) = @_; return $self->actions->{$name} if defined $self->actions->{$name};