Stop confusing future readers by removing code that doesn't actually do anything.
[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;
531f1ab6 19with 'MooseX::Emulate::Class::Accessor::Fast';
cfd04b0c 20
b8ea7be4 21has part => (is => 'rw', required => 1);
059c085b 22has actions => (is => 'rw', required => 1, lazy => 1, default => sub { {} });
a13e21ab 23
4090e3bb 24around new => sub {
25 my ($orig, $self, $params) = @_;
26 $orig->($self, (ref($params) ? $params : { part => $params } ));
27};
cfd04b0c 28
4090e3bb 29no Moose;
cfd04b0c 30
9b73c5e7 31use overload (
32 # Stringify to path part for tree search
33 q{""} => sub { shift->part },
34);
35
b2ddf6d7 36sub get_action {
37 my ( $self, $name ) = @_;
38 return $self->actions->{$name} if defined $self->actions->{$name};
39 return;
40}
cfd04b0c 41
b2ddf6d7 42sub add_action {
43 my ( $self, $action, $name ) = @_;
44 $name ||= $action->name;
45 $self->actions->{$name} = $action;
46}
cfd04b0c 47
e5ecd5bc 48__PACKAGE__->meta->make_immutable;
49
b2ddf6d7 501;
cfd04b0c 51
b2ddf6d7 52__END__
649fd1fa 53
cfd04b0c 54=head1 METHODS
55
d4c74714 56=head2 new(\%data | $part)
57
58Can be called with { part => $part, actions => \%actions } for full
59construction or with just a part, which will result in an empty actions
60hashref to be populated via add_action later
61
649fd1fa 62=head2 get_action($name)
63
64Returns an action from this container based on the action name, or undef
79a3189a 65
a13e21ab 66=head2 add_action($action, [ $name ])
67
68Adds an action, optionally providing a name to override $action->name
69
b5ecfcf0 70=head2 actions
79a3189a 71
649fd1fa 72Accessor to the actions hashref, containing all actions in this container.
73
b5ecfcf0 74=head2 part
cfd04b0c 75
649fd1fa 76Accessor to the path part this container resolves to. Also what the container
77stringifies to.
78
059c085b 79=head2 meta
80
81Provided by Moose
82
2f381252 83=head1 AUTHORS
cfd04b0c 84
2f381252 85Catalyst Contributors, see Catalyst.pm
cfd04b0c 86
87=head1 COPYRIGHT
88
89This program is free software, you can redistribute it and/or modify it under
90the same terms as Perl itself.
91
92=cut
93
941;