line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::ActionContainer; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Catalyst::ActionContainer - Catalyst Action Container |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
See L<Catalyst>. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
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. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
155
|
|
|
155
|
|
5153
|
use Moose; |
|
155
|
|
|
|
|
522
|
|
|
155
|
|
|
|
|
1601
|
|
19
|
|
|
|
|
|
|
with 'MooseX::Emulate::Class::Accessor::Fast'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has part => (is => 'rw', required => 1); |
22
|
|
|
|
|
|
|
has actions => (is => 'rw', required => 1, lazy => 1, default => sub { {} }); |
23
|
|
|
|
|
|
|
|
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); |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
155
|
|
|
155
|
|
1142120
|
no Moose; |
|
155
|
|
|
|
|
561
|
|
|
155
|
|
|
|
|
1255
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use overload ( |
33
|
|
|
|
|
|
|
# Stringify to path part for tree search |
34
|
33
|
|
|
33
|
|
1121
|
q{""} => sub { shift->part }, |
35
|
155
|
|
|
155
|
|
43227
|
); |
|
155
|
|
|
|
|
483
|
|
|
155
|
|
|
|
|
1981
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub get_action { |
38
|
6202
|
|
|
6202
|
1
|
12481
|
my ( $self, $name ) = @_; |
39
|
6202
|
100
|
|
|
|
181941
|
return $self->actions->{$name} if defined $self->actions->{$name}; |
40
|
4673
|
|
|
|
|
16173
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub add_action { |
44
|
69204
|
|
|
69204
|
1
|
139542
|
my ( $self, $action, $name ) = @_; |
45
|
69204
|
|
33
|
|
|
1937066
|
$name ||= $action->name; |
46
|
69204
|
|
|
|
|
1988415
|
$self->actions->{$name} = $action; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 new(\%data | $part) |
58
|
|
|
|
|
|
|
|
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 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 get_action($name) |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns an action from this container based on the action name, or undef |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 add_action($action, [ $name ]) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Adds an action, optionally providing a name to override $action->name |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 actions |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Accessor to the actions hashref, containing all actions in this container. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 part |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Accessor to the path part this container resolves to. Also what the container |
78
|
|
|
|
|
|
|
stringifies to. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 meta |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Provided by Moose |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHORS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Catalyst Contributors, see Catalyst.pm |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify it under |
91
|
|
|
|
|
|
|
the same terms as Perl itself. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |