authors cleanup
[catagits/Catalyst-Runtime.git] / lib / Catalyst / ActionContainer.pm
CommitLineData
cfd04b0c 1package Catalyst::ActionContainer;
2
3use strict;
4use base qw/Class::Accessor::Fast/;
5
b2ddf6d7 6=head1 NAME
7
8Catalyst::ActionContainer - Catalyst Action Container
9
10=head1 SYNOPSIS
11
12See L<Catalyst>.
13
14=head1 DESCRIPTION
15
16This is a container for actions. The dispatcher sets up a tree of these
17to represent the various dispatch points in your application.
18
19=cut
20
cfd04b0c 21__PACKAGE__->mk_accessors(qw/part actions/);
22
23use overload (
24
25 # Stringify to path part for tree search
26 q{""} => sub { shift->{part} },
27
28);
29
a13e21ab 30sub new {
31 my ( $class, $fields ) = @_;
32
33 $fields = { part => $fields, actions => {} } unless ref $fields;
34
35 $class->SUPER::new($fields);
36}
37
cfd04b0c 38
cfd04b0c 39
b2ddf6d7 40sub get_action {
41 my ( $self, $name ) = @_;
42 return $self->actions->{$name} if defined $self->actions->{$name};
43 return;
44}
cfd04b0c 45
b2ddf6d7 46sub add_action {
47 my ( $self, $action, $name ) = @_;
48 $name ||= $action->name;
49 $self->actions->{$name} = $action;
50}
cfd04b0c 51
b2ddf6d7 521;
cfd04b0c 53
b2ddf6d7 54__END__
649fd1fa 55
cfd04b0c 56=head1 METHODS
57
d4c74714 58=head2 new(\%data | $part)
59
60Can be called with { part => $part, actions => \%actions } for full
61construction or with just a part, which will result in an empty actions
62hashref to be populated via add_action later
63
649fd1fa 64=head2 get_action($name)
65
66Returns an action from this container based on the action name, or undef
79a3189a 67
a13e21ab 68=head2 add_action($action, [ $name ])
69
70Adds an action, optionally providing a name to override $action->name
71
b5ecfcf0 72=head2 actions
79a3189a 73
649fd1fa 74Accessor to the actions hashref, containing all actions in this container.
75
b5ecfcf0 76=head2 part
cfd04b0c 77
649fd1fa 78Accessor to the path part this container resolves to. Also what the container
79stringifies to.
80
0bf7ab71 81=head1 AUTHORS
cfd04b0c 82
0bf7ab71 83Catalyst Contributors, see Catalyst.pm
cfd04b0c 84
85=head1 COPYRIGHT
86
87This program is free software, you can redistribute it and/or modify it under
88the same terms as Perl itself.
89
90=cut
91
921;