1 package Catalyst::ActionContainer;
5 Catalyst::ActionContainer - Catalyst Action Container
13 This is a container for actions. The dispatcher sets up a tree of these
14 to represent the various dispatch points in your application.
19 with 'MooseX::Emulate::Class::Accessor::Fast';
21 has part => (is => 'rw', required => 1);
22 has actions => (is => 'rw', required => 1, lazy => 1, default => sub { {} });
24 around BUILDARGS => sub {
25 my ($next, $self, @args) = @_;
26 unshift @args, 'part' if scalar @args == 1 && !ref $args[0];
27 return $self->$next(@args);
33 # Stringify to path part for tree search
34 q{""} => sub { shift->part },
38 my ( $self, $name ) = @_;
39 return $self->actions->{$name} if defined $self->actions->{$name};
44 my ( $self, $action, $name ) = @_;
45 $name ||= $action->name;
46 $self->actions->{$name} = $action;
49 __PACKAGE__->meta->make_immutable;
57 =head2 new(\%data | $part)
59 Can be called with { part => $part, actions => \%actions } for full
60 construction or with just a part, which will result in an empty actions
61 hashref to be populated via add_action later
63 =head2 get_action($name)
65 Returns an action from this container based on the action name, or undef
67 =head2 add_action($action, [ $name ])
69 Adds an action, optionally providing a name to override $action->name
73 Accessor to the actions hashref, containing all actions in this container.
77 Accessor to the path part this container resolves to. Also what the container
86 Catalyst Contributors, see Catalyst.pm
90 This library is free software. You can redistribute it and/or modify it under
91 the same terms as Perl itself.