Fix ROADMAP url.
[catagits/Catalyst-Runtime.git] / lib / Catalyst / ActionContainer.pm
CommitLineData
cfd04b0c 1package Catalyst::ActionContainer;
2
b2ddf6d7 3=head1 NAME
4
5Catalyst::ActionContainer - Catalyst Action Container
6
7=head1 SYNOPSIS
8
9See L<Catalyst>.
10
11=head1 DESCRIPTION
12
13This is a container for actions. The dispatcher sets up a tree of these
14to represent the various dispatch points in your application.
15
16=cut
17
059c085b 18use Moose;
cfd04b0c 19
5fb12dbb 20has part => (is => 'rw', required => 1, lazy => 1, default => sub { {} });
059c085b 21has actions => (is => 'rw', required => 1, lazy => 1, default => sub { {} });
a13e21ab 22
4090e3bb 23around new => sub {
24 my ($orig, $self, $params) = @_;
25 $orig->($self, (ref($params) ? $params : { part => $params } ));
26};
cfd04b0c 27
4090e3bb 28no Moose;
cfd04b0c 29
b2ddf6d7 30sub get_action {
31 my ( $self, $name ) = @_;
32 return $self->actions->{$name} if defined $self->actions->{$name};
33 return;
34}
cfd04b0c 35
b2ddf6d7 36sub add_action {
37 my ( $self, $action, $name ) = @_;
38 $name ||= $action->name;
39 $self->actions->{$name} = $action;
40}
cfd04b0c 41
e5ecd5bc 42__PACKAGE__->meta->make_immutable;
43
b2ddf6d7 441;
cfd04b0c 45
b2ddf6d7 46__END__
649fd1fa 47
cfd04b0c 48=head1 METHODS
49
d4c74714 50=head2 new(\%data | $part)
51
52Can be called with { part => $part, actions => \%actions } for full
53construction or with just a part, which will result in an empty actions
54hashref to be populated via add_action later
55
649fd1fa 56=head2 get_action($name)
57
58Returns an action from this container based on the action name, or undef
79a3189a 59
a13e21ab 60=head2 add_action($action, [ $name ])
61
62Adds an action, optionally providing a name to override $action->name
63
b5ecfcf0 64=head2 actions
79a3189a 65
649fd1fa 66Accessor to the actions hashref, containing all actions in this container.
67
b5ecfcf0 68=head2 part
cfd04b0c 69
649fd1fa 70Accessor to the path part this container resolves to. Also what the container
71stringifies to.
72
059c085b 73=head2 meta
74
75Provided by Moose
76
2f381252 77=head1 AUTHORS
cfd04b0c 78
2f381252 79Catalyst Contributors, see Catalyst.pm
cfd04b0c 80
81=head1 COPYRIGHT
82
83This program is free software, you can redistribute it and/or modify it under
84the same terms as Perl itself.
85
86=cut
87
881;