1 package Catalyst::ActionContainer;
4 use base qw/Class::Accessor::Fast/;
6 __PACKAGE__->mk_accessors(qw/part actions/);
10 # Stringify to path part for tree search
11 q{""} => sub { shift->{part} },
16 my ( $class, $fields ) = @_;
18 $fields = { part => $fields, actions => {} } unless ref $fields;
20 $class->SUPER::new($fields);
25 Catalyst::ActionContainer - Catalyst Action Container
33 This is a container for actions. The dispatcher sets up a tree of these
34 to represent the various dispatch points in your application.
38 =head2 new(\%data | $part)
40 Can be called with { part => $part, actions => \%actions } for full
41 construction or with just a part, which will result in an empty actions
42 hashref to be populated via add_action later
44 =head2 get_action($name)
46 Returns an action from this container based on the action name, or undef
51 my ( $self, $name ) = @_;
52 return $self->actions->{$name} if defined $self->actions->{$name};
56 =head2 add_action($action, [ $name ])
58 Adds an action, optionally providing a name to override $action->name
63 my ( $self, $action, $name ) = @_;
64 $name ||= $action->name;
65 $self->actions->{$name} = $action;
70 Accessor to the actions hashref, containing all actions in this container.
74 Accessor to the path part this container resolves to. Also what the container
83 This program is free software, you can redistribute it and/or modify it under
84 the same terms as Perl itself.