| 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 | 154 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 154 | with 'MooseX::Emulate::Class::Accessor::Fast'; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 154 | has part => (is => 'rw', required => 1); | |||||||||||||||||||||||||||
| 22 | 5915 | ▶ | has actions => (is => 'rw', required => 1, lazy => 1, default => sub { {} }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 6322 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 25 | 6322 | my ($next, $self, @args) = @_; | |||||||||||||||||||||||||||
| 26 | 6322 | ▶ | unshift @args, 'part' if scalar @args == 1 && !ref $args[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar @args == 1 and not ref $args[0]
MC/DC50%1/2
scalar @args == 1 and not ref $args[0]
scalar @args == 1
not ref $args[0]
Truth table66%2/3
A and not(B)
A= scalar @args == 1B= not ref $args[0]
| |||||||||||||||||||||||||||||
| 27 | 6322 | return $self->$next(@args); | |||||||||||||||||||||||||||
| 28 | 154 | }; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 154 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 154 | ▶ | use overload ( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | # Stringify to path part for tree search | ||||||||||||||||||||||||||||
| 34 | 22 | ▶ | q{""} => sub { shift->part }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | 154 | ); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 6229 | ▶ | sub get_action { | ||||||||||||||||||||||||||
|
Subroutine
get_action: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 6229 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||
| 39 | 6229 | ▶ | return $self->actions->{$name} if defined $self->actions->{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 4694 | return; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 66249 | ▶ | sub add_action { | ||||||||||||||||||||||||||
|
Subroutine
add_action: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 66249 | my ( $self, $action, $name ) = @_; | |||||||||||||||||||||||||||
| 45 | 66249 | ▶ | $name ||= $action->name; | ||||||||||||||||||||||||||
|
Condition33%1/3
$name ||= $action->name
MC/DC0%0/2
$name ||= $action->name
$name
$action->name
Truth table33%1/3
A ||= B
A= $nameB= $action->name
| |||||||||||||||||||||||||||||
| 46 | 66249 | $self->actions->{$name} = $action; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 154 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 154 | 1; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||