| 1 | package Catalyst::Controller; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 166 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 166 | ▶ | use Class::MOP; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 166 | ▶ | use Class::Load ':all'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 166 | ▶ | use String::RewritePrefix; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 166 | ▶ | use Moose::Util qw/find_meta/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 166 | ▶ | use List::Util qw/first uniq/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 166 | ▶ | use namespace::clean -except => 'meta'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 166 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 166 | extends qw/Catalyst::Component/; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 166 | with qw/MooseX::MethodAttributes::Role::AttrContainer::Inheritable/; | |||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 166 | ▶ | use MooseX::MethodAttributes; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 166 | ▶ | use Catalyst::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 166 | ▶ | use Catalyst::Utils; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 166 | with 'Catalyst::Component::ApplicationAttribute'; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 166 | has path_prefix => ( | |||||||||||||||||||||||||||||||||||||||||
| 23 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | init_arg => 'path', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | predicate => 'has_path_prefix', | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 166 | has action_namespace => ( | |||||||||||||||||||||||||||||||||||||||||
| 30 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | init_arg => 'namespace', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | predicate => 'has_action_namespace', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 166 | has actions => ( | |||||||||||||||||||||||||||||||||||||||||
| 37 | accessor => '_controller_actions', | ||||||||||||||||||||||||||||||||||||||||||
| 38 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||
| 39 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | has _action_role_args => ( | ||||||||||||||||||||||||||||||||||||||||||
| 43 | traits => [qw(Array)], | ||||||||||||||||||||||||||||||||||||||||||
| 44 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | init_arg => 'action_roles', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 6935 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 166 | handles => { | |||||||||||||||||||||||||||||||||||||||||
| 48 | _action_role_args => 'elements', | ||||||||||||||||||||||||||||||||||||||||||
| 49 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 166 | has _action_roles => ( | |||||||||||||||||||||||||||||||||||||||||
| 53 | traits => [qw(Array)], | ||||||||||||||||||||||||||||||||||||||||||
| 54 | isa => 'ArrayRef[RoleName]', | ||||||||||||||||||||||||||||||||||||||||||
| 55 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | builder => '_build__action_roles', | ||||||||||||||||||||||||||||||||||||||||||
| 58 | handles => { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | _action_roles => 'elements', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 166 | has action_args => (is => 'ro'); | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | # ->config(actions => { '*' => ... | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 166 | has _all_actions_attributes => ( | |||||||||||||||||||||||||||||||||||||||||
| 67 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 68 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||
| 69 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | builder => '_build__all_actions_attributes', | ||||||||||||||||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 7013 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 7013 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 7013 | ▶ | my $action = delete $args->{action} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args->{'action'} || {}
MC/DC100%1/1
delete $args->{'action'} || {}
delete $args->{'action'}
Truth table100%2/2
A
A= delete $args->{'action'}
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 7013 | ▶ | my $actions = delete $args->{actions} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args->{'actions'} || {}
MC/DC100%1/1
delete $args->{'actions'} || {}
delete $args->{'actions'}
Truth table100%2/2
A
A= delete $args->{'actions'}
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 7013 | my $attr_value = $self->merge_config_hashes($actions, $action); | |||||||||||||||||||||||||||||||||||||||||
| 79 | 7013 | $self->_controller_actions($attr_value); | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | # trigger lazy builder | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 7013 | $self->_all_actions_attributes; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 7013 | $self->_action_roles; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 7013 | ▶ | sub _build__action_roles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__action_roles: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 7013 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 7013 | my @roles = $self->_expand_role_shortname($self->_action_role_args); | |||||||||||||||||||||||||||||||||||||||||
| 89 | 7013 | load_class($_) for @roles; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 7013 | return \@roles; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 7013 | ▶ | sub _build__all_actions_attributes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__all_actions_attributes: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 7013 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 7013 | ▶ | delete $self->_controller_actions->{'*'} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | Catalyst::Controller - Catalyst Controller base class | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | package MyApp::Controller::Search | ||||||||||||||||||||||||||||||||||||||||||
| 105 | use base qw/Catalyst::Controller/; | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | sub foo : Local { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | my ($self,$c,@args) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 109 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 110 | } # Dispatches to /search/foo | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | Controllers are where the actions in the Catalyst framework | ||||||||||||||||||||||||||||||||||||||||||
| 115 | reside. Each action is represented by a function with an attribute to | ||||||||||||||||||||||||||||||||||||||||||
| 116 | identify what kind of action it is. See the L<Catalyst::Dispatcher> | ||||||||||||||||||||||||||||||||||||||||||
| 117 | for more info about how Catalyst dispatches to actions. | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | #I think both of these could be attributes. doesn't really seem like they need | ||||||||||||||||||||||||||||||||||||||||||
| 122 | #to be class data. i think that attributes +default would work just fine | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 166 | __PACKAGE__->mk_classdata($_) for qw/_dispatch_steps _action_class _action_role_prefix/; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 166 | __PACKAGE__->_dispatch_steps( [qw/_BEGIN _AUTO _ACTION/] ); | |||||||||||||||||||||||||||||||||||||||||
| 126 | 166 | __PACKAGE__->_action_class('Catalyst::Action'); | |||||||||||||||||||||||||||||||||||||||||
| 127 | 166 | __PACKAGE__->_action_role_prefix([ 'Catalyst::ActionRole::' ]); | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 964 | ▶ | sub _DISPATCH : Private { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_DISPATCH: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 964 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 964 | foreach my $disp ( @{ $self->_dispatch_steps } ) { | |||||||||||||||||||||||||||||||||||||||||
| 134 | 2886 | ▶ | last unless $c->forward($disp); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 938 | $c->forward('_END'); | |||||||||||||||||||||||||||||||||||||||||
| 138 | 166 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 964 | ▶ | sub _BEGIN : Private { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_BEGIN: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 964 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 964 | my $begin = ( $c->get_actions( 'begin', $c->namespace ) )[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 964 | ▶ | return 1 unless $begin; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 301 | $begin->dispatch( $c ); | |||||||||||||||||||||||||||||||||||||||||
| 145 | #If there is an error, all bets off | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 301 | ▶ | if( @{ $c->error }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return !@{ $c->error }; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 301 | ▶ | return $c->state || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$c->state || 1
MC/DC100%1/1
$c->state || 1
$c->state
Truth table100%2/2
A
A= $c->state
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 166 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 964 | ▶ | sub _AUTO : Private { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_AUTO: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 964 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 964 | my @auto = $c->get_actions( 'auto', $c->namespace ); | |||||||||||||||||||||||||||||||||||||||||
| 156 | 964 | foreach my $auto (@auto) { | |||||||||||||||||||||||||||||||||||||||||
| 157 | # We FORCE the auto action user to explicitly return | ||||||||||||||||||||||||||||||||||||||||||
| 158 | # true. We need to do this since there's some auto | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # users (Catalyst::Authentication::Credential::HTTP) that | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # actually do a detach instead. | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 40 | $c->state(0); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 40 | $auto->dispatch( $c ); | |||||||||||||||||||||||||||||||||||||||||
| 163 | 36 | ▶ | return 0 unless $c->state; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 958 | ▶ | return $c->state || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$c->state || 1
MC/DC100%1/1
$c->state || 1
$c->state
Truth table100%2/2
A
A= $c->state
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 166 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 958 | ▶ | sub _ACTION : Private { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ACTION: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 958 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 958 | ▶ | if ( ref $c->action | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $c->action and $c->action->can("execute") and defined $c->req->action
ref $c->action and $c->action->can("execute")
MC/DC0%0/3
ref $c->action and $c->action->can("execute") and defined $c->req->action
ref $c->action
$c->action->can("execute")
defined $c->req->action
Truth table25%1/4
A and B and C
A= ref $c->actionB= $c->action->can("execute")C= defined $c->req->action
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | && $c->action->can('execute') | ||||||||||||||||||||||||||||||||||||||||||
| 172 | && defined $c->req->action ) | ||||||||||||||||||||||||||||||||||||||||||
| 173 | { | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 958 | $c->action->dispatch( $c ); | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | #If there is an error, all bets off | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 927 | ▶ | if( @{ $c->error }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 26 | return !@{ $c->error }; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 901 | ▶ | return $c->state || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$c->state || 1
MC/DC100%1/1
$c->state || 1
$c->state
Truth table100%2/2
A
A= $c->state
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 166 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 938 | ▶ | sub _END : Private { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_END: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 938 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 938 | my $end = ( $c->get_actions( 'end', $c->namespace ) )[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 938 | ▶ | return 1 unless $end; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 650 | $end->dispatch( $c ); | |||||||||||||||||||||||||||||||||||||||||
| 189 | 649 | return !@{ $c->error }; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 166 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 65 | ▶ | sub action_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
action_for: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 65 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 65 | ▶ | my $app = ($self->isa('Catalyst') ? $self : $self->_application); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 65 | return $app->dispatcher->get_action($name, $self->action_namespace); | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | #my opinion is that this whole sub really should be a builder method, not | ||||||||||||||||||||||||||||||||||||||||||
| 199 | #something that happens on every call. Anyone else disagree?? -- groditi | ||||||||||||||||||||||||||||||||||||||||||
| 200 | ## -- apparently this is all just waiting for app/ctx split | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 16318 | ▶ | around action_namespace => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 16318 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 16318 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 16318 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table66%2/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 16318 | ▶ | my $appclass = ref($c) || $c; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $c || $c
MC/DC50%1/2
ref $c || $c
ref $c
$c
Truth table66%2/3
A || B
A= ref $cB= $c
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 16318 | ▶ | if( ref($self) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 16170 | ▶ | return $self->$orig if $self->has_action_namespace; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 148 | ▶ | return $class->config->{namespace} if exists $class->config->{namespace}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 5984 | my $case_s; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 5984 | ▶ | if( $c ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 5980 | $case_s = $appclass->config->{case_sensitive}; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 4 | ▶ | if ($self->isa('Catalyst')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | $case_s = $class->config->{case_sensitive}; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if (ref $self) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $case_s = ref($self->_application)->config->{case_sensitive}; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | confess("Can't figure out case_sensitive setting"); | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 5984 | ▶ | my $namespace = Catalyst::Utils::class2prefix($self->catalyst_component_name, $case_s) || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
Catalyst::Utils::class2prefix($self->catalyst_component_name, $case_s) || ''
MC/DC100%1/1
Catalyst::Utils::class2prefix($self->catalyst_component_name, $case_s) || ''
Catalyst::Utils::class2prefix($self->catalyst_component_name, $case_s)
Truth table100%2/2
A
A= Catalyst::Utils::class2prefix($self->catalyst_component_name, $case_s)
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 5984 | ▶ | $self->$orig($namespace) if ref($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 5984 | return $namespace; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 166 | }; | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | #Once again, this is probably better written as a builder method | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 13056 | ▶ | around path_prefix => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 13056 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 13056 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 13056 | ▶ | if( ref($self) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 13054 | ▶ | return $self->$orig if $self->has_path_prefix; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | ▶ | return $self->config->{path} if exists $self->config->{path}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 3188 | my $namespace = $self->action_namespace(@_); | |||||||||||||||||||||||||||||||||||||||||
| 243 | 3188 | ▶ | $self->$orig($namespace) if ref($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 3188 | return $namespace; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 166 | }; | |||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 6257 | ▶ | sub get_action_methods { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_action_methods: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 6257 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 6257 | ▶ | my $meta = find_meta($self) || confess("No metaclass setup for $self"); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
find_meta($self) || confess("No metaclass setup for $self")
MC/DC0%0/1
find_meta($self) || confess("No metaclass setup for $self")
find_meta($self)
Truth table50%1/2
A
A= find_meta($self)
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 6257 | ▶ | confess( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | sprintf "Metaclass %s for %s cannot support register_actions.", | ||||||||||||||||||||||||||||||||||||||||||
| 252 | ref $meta, $meta->name, | ||||||||||||||||||||||||||||||||||||||||||
| 253 | ) unless $meta->can('get_nearest_methods_with_attributes'); | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 6257 | my @methods = $meta->get_nearest_methods_with_attributes; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | # actions specified via config are also action_methods | ||||||||||||||||||||||||||||||||||||||||||
| 257 | push( | ||||||||||||||||||||||||||||||||||||||||||
| 258 | @methods, | ||||||||||||||||||||||||||||||||||||||||||
| 259 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 625 | ▶ | $meta->find_method_by_name($_) | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$meta->find_method_by_name($_) || confess(sprintf('Action "%s" is not available from controller %s', $_, ref $self))
MC/DC0%0/1
$meta->find_method_by_name($_) || confess(sprintf('Action "%s" is not available from controller %s', $_, ref $self))
$meta->find_method_by_name($_)
Truth table50%1/2
A
A= $meta->find_method_by_name($_)
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | || confess( sprintf 'Action "%s" is not available from controller %s', | ||||||||||||||||||||||||||||||||||||||||||
| 262 | $_, ref $self ) | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 6257 | ▶ | } keys %{ $self->_controller_actions } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | ) if ( ref $self ); | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 6257 | return uniq @methods; | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 6255 | ▶ | sub register_actions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_actions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 6255 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 6255 | $self->register_action_methods( $c, $self->get_action_methods ); | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 6255 | ▶ | sub register_action_methods { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_action_methods: called CC=11 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 6255 | my ( $self, $c, @methods ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 6255 | my $class = $self->catalyst_component_name; | |||||||||||||||||||||||||||||||||||||||||
| 277 | #this is still not correct for some reason. | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 6255 | my $namespace = $self->action_namespace($c); | |||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | # FIXME - fugly | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 6255 | ▶ | if (!blessed($self) && $self eq $c && scalar(@methods)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not builtin::blessed($self) and $self eq $c and scalar @methods
not builtin::blessed($self) and $self eq $c
MC/DC50%1/2
not builtin::blessed($self) and $self eq $c and scalar @methods
not builtin::blessed($self)
$self eq $c
Truth table66%2/3
not(A) and B
A= not builtin::blessed($self)B= $self eq $c
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 143 | my @really_bad_methods = grep { ! /^_(DISPATCH|BEGIN|AUTO|ACTION|END)$/ } map { $_->name } @methods; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 143 | ▶ | if (scalar(@really_bad_methods)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 2 | $c->log->warn("Action methods (" . join(', ', @really_bad_methods) . ") found defined in your application class, $self. This is deprecated, please move them into a Root controller."); | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 6255 | foreach my $method (@methods) { | |||||||||||||||||||||||||||||||||||||||||
| 289 | 66250 | my $name = $method->name; | |||||||||||||||||||||||||||||||||||||||||
| 290 | # Horrible hack! All method metaclasses should have an attributes | ||||||||||||||||||||||||||||||||||||||||||
| 291 | # method, core Moose bug - see r13354. | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 66250 | ▶ | my $attributes = $method->can('attributes') ? $method->attributes : []; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 66250 | my $attrs = $self->_parse_attrs( $c, $name, @{ $attributes } ); | |||||||||||||||||||||||||||||||||||||||||
| 294 | 66250 | ▶ | if ( $attrs->{Private} && ( keys %$attrs > 1 ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$attrs->{"Private"} and keys %$attrs > 1
MC/DC0%0/2
$attrs->{"Private"} and keys %$attrs > 1
$attrs->{"Private"}
keys %$attrs > 1
Truth table66%2/3
A and B
A= $attrs->{"Private"}B= keys %$attrs > 1
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | $c->log->warn( 'Bad action definition "' | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | . join( ' ', @{ $attributes } ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | . qq/" for "$class->$name"/ ) | ||||||||||||||||||||||||||||||||||||||||||
| 298 | if $c->debug; | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 66250 | ▶ | my $reverse = $namespace ? "${namespace}/${name}" : $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 66250 | my $action = $self->create_action( | |||||||||||||||||||||||||||||||||||||||||
| 303 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 304 | code => $method->body, | ||||||||||||||||||||||||||||||||||||||||||
| 305 | reverse => $reverse, | ||||||||||||||||||||||||||||||||||||||||||
| 306 | namespace => $namespace, | ||||||||||||||||||||||||||||||||||||||||||
| 307 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||
| 308 | attributes => $attrs, | ||||||||||||||||||||||||||||||||||||||||||
| 309 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 66250 | $c->dispatcher->register( $c, $action ); | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 1752 | ▶ | sub _apply_action_class_roles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_action_class_roles: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 1752 | my ($self, $class, @roles) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 1752 | load_class($_) for @roles; | |||||||||||||||||||||||||||||||||||||||||
| 319 | 1752 | my $meta = Moose::Meta::Class->initialize($class)->create_anon_class( | |||||||||||||||||||||||||||||||||||||||||
| 320 | superclasses => [$class], | ||||||||||||||||||||||||||||||||||||||||||
| 321 | roles => \@roles, | ||||||||||||||||||||||||||||||||||||||||||
| 322 | cache => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 323 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | $meta->add_method(meta => sub { $meta }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
Subroutine
meta: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 1752 | return $meta->name; | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 66250 | ▶ | sub action_class { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
action_class: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 66250 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 331 | 66250 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | my $class = (exists $args{attributes}{ActionClass} | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 66250 | ▶ | ? $args{attributes}{ActionClass}[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | : $self->_action_class); | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 66250 | load_class($class); | |||||||||||||||||||||||||||||||||||||||||
| 338 | 66250 | return $class; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 66250 | ▶ | sub create_action { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_action: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 66250 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 66250 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 66250 | my $class = $self->action_class(%args); | |||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 66250 | load_class($class); | |||||||||||||||||||||||||||||||||||||||||
| 348 | 66250 | ▶ | Moose->init_meta(for_class => $class) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | unless Class::MOP::does_metaclass_exist($class); | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 66250 | ▶ | unless ($args{name} =~ /^_(DISPATCH|BEGIN|AUTO|ACTION|END)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 34975 | my @roles = $self->gather_action_roles(%args); | |||||||||||||||||||||||||||||||||||||||||
| 353 | 34975 | push @roles, $self->gather_default_action_roles(%args); | |||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 34975 | ▶ | $class = $self->_apply_action_class_roles($class, @roles) if @roles; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | my $action_args = ( | ||||||||||||||||||||||||||||||||||||||||||
| 359 | ref($self) | ||||||||||||||||||||||||||||||||||||||||||
| 360 | ? $self->action_args | ||||||||||||||||||||||||||||||||||||||||||
| 361 | : $self->config->{action_args} | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 66250 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | my %extra_args = ( | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 66250 | ▶ | %{ $action_args->{'*'} || {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$action_args->{'*'} || {}
MC/DC100%1/1
$action_args->{'*'} || {}
$action_args->{'*'}
Truth table100%2/2
A
A= $action_args->{'*'}
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 66250 | ▶ | %{ $action_args->{ $args{name} } || {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$action_args{$args{'name'}} || {}
MC/DC100%1/1
$$action_args{$args{'name'}} || {}
$$action_args{$args{'name'}}
Truth table100%2/2
A
A= $$action_args{$args{'name'}}
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 66250 | return $class->new({ %extra_args, %args }); | |||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 34975 | ▶ | sub gather_action_roles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gather_action_roles: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 34975 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 374 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 375 | (blessed $self ? $self->_action_roles : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 34975 | ▶ | @{ $args{attributes}->{Does} || [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$args{'attributes'}{'Does'} || []
MC/DC100%1/1
$args{'attributes'}{'Does'} || []
$args{'attributes'}{'Does'}
Truth table100%2/2
A
A= $args{'attributes'}{'Does'}
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 34975 | ▶ | sub gather_default_action_roles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gather_default_action_roles: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 34975 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 382 | 34975 | my @roles = (); | |||||||||||||||||||||||||||||||||||||||||
| 383 | push @roles, 'Catalyst::ActionRole::HTTPMethods' | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 34975 | ▶ | if $args{attributes}->{Method}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | push @roles, 'Catalyst::ActionRole::ConsumesContent' | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 34975 | ▶ | if $args{attributes}->{Consumes}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | push @roles, 'Catalyst::ActionRole::Scheme' | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 34975 | ▶ | if $args{attributes}->{Scheme}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | push @roles, 'Catalyst::ActionRole::QueryMatching' | ||||||||||||||||||||||||||||||||||||||||||
| 393 | 34975 | ▶ | if $args{attributes}->{Query}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 34975 | return @roles; | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 94815 | ▶ | sub _parse_attr_key_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_attr_key_value: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 94815 | my ( $self, $c, $attr ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 94815 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | my ( $key, $value ) = $attr =~ m{ | ||||||||||||||||||||||||||||||||||||||||||
| 401 | \A | ||||||||||||||||||||||||||||||||||||||||||
| 402 | (\S*?) # match the key e.g. Foo in example | ||||||||||||||||||||||||||||||||||||||||||
| 403 | (?: | ||||||||||||||||||||||||||||||||||||||||||
| 404 | \( \s* | ||||||||||||||||||||||||||||||||||||||||||
| 405 | (.+?)? # match attr content e.g. "bar" in example | ||||||||||||||||||||||||||||||||||||||||||
| 406 | \s* \) | ||||||||||||||||||||||||||||||||||||||||||
| 407 | )? | ||||||||||||||||||||||||||||||||||||||||||
| 408 | \z | ||||||||||||||||||||||||||||||||||||||||||
| 409 | }xms | ||||||||||||||||||||||||||||||||||||||||||
| 410 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 411 | { | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 94815 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 36741 | ▶ | ( $value =~ s/^'(.*)'$/$1/ ) || ( $value =~ s/^"(.*)"/$1/ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 94815 | return ( $key, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 66250 | ▶ | sub _parse_attrs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_attrs: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 66250 | my ( $self, $c, $name, @attrs ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 66250 | my %raw_attributes; | |||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 66250 | foreach my $attr (@attrs) { | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | # Parse out :Foo(bar) into Foo => bar etc (and arrayify) | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 94815 | my ( $key, $value ) = $self->_parse_attr_key_value( $c, $attr ); | |||||||||||||||||||||||||||||||||||||||||
| 430 | 94815 | ▶ | if ( defined $key ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 94815 | push @{ $raw_attributes{$key} }, $value; | |||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | $c->log->warn( qq/Unknown attribute "$attr" for "$name"/ ) if $c->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 66250 | my ($actions_config, $all_actions_config); | |||||||||||||||||||||||||||||||||||||||||
| 439 | 66250 | ▶ | if( ref($self) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 65533 | $actions_config = $self->_controller_actions; | |||||||||||||||||||||||||||||||||||||||||
| 441 | # No, you're not getting actions => { '*' => ... } with actions in MyApp. | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 65533 | $all_actions_config = $self->_all_actions_attributes; | |||||||||||||||||||||||||||||||||||||||||
| 443 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 717 | my $cfg = $self->config; | |||||||||||||||||||||||||||||||||||||||||
| 445 | 717 | $actions_config = $self->merge_config_hashes($cfg->{actions}, $cfg->{action}); | |||||||||||||||||||||||||||||||||||||||||
| 446 | 717 | $all_actions_config = {}; | |||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | %raw_attributes = ( | ||||||||||||||||||||||||||||||||||||||||||
| 450 | %raw_attributes, | ||||||||||||||||||||||||||||||||||||||||||
| 451 | # Note we deep copy array refs here to stop crapping on config | ||||||||||||||||||||||||||||||||||||||||||
| 452 | # when attributes are parsed. RT#65463 | ||||||||||||||||||||||||||||||||||||||||||
| 453 | 66250 | ▶ | exists $actions_config->{$name} ? map { ref($_) eq 'ARRAY' ? [ @$_ ] : $_ } %{ $actions_config->{$name } } : (), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | # Private actions with additional attributes will raise a warning and then | ||||||||||||||||||||||||||||||||||||||||||
| 457 | # be ignored. Adding '*' arguments to the default _DISPATCH / etc. methods, | ||||||||||||||||||||||||||||||||||||||||||
| 458 | # which are Private, will prevent those from being registered. They should | ||||||||||||||||||||||||||||||||||||||||||
| 459 | # probably be turned into :Actions instead, or we might want to otherwise | ||||||||||||||||||||||||||||||||||||||||||
| 460 | # disambiguate between those built-in internal actions and user-level | ||||||||||||||||||||||||||||||||||||||||||
| 461 | # Private ones. | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 26379 | %raw_attributes = (%{ $all_actions_config }, %raw_attributes) | |||||||||||||||||||||||||||||||||||||||||
| 463 | 66250 | ▶ | unless $raw_attributes{Private}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 66250 | my %final_attributes; | |||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 66250 | ▶ | while (my ($key, $value) = each %raw_attributes){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 92864 | my $new_attrs = $self->_parse_attr($c, $name, $key => $value ); | |||||||||||||||||||||||||||||||||||||||||
| 469 | 92864 | push @{ $final_attributes{$_} }, @{ $new_attrs->{$_} } for keys %$new_attrs; | |||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 66250 | return \%final_attributes; | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | 107755 | ▶ | sub _parse_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_attr: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 107755 | my ($self, $c, $name, $key, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 107755 | my %final_attributes; | |||||||||||||||||||||||||||||||||||||||||
| 479 | 107755 | ▶ | foreach my $value (ref($values) eq 'ARRAY' ? @$values : $values) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 110954 | my $meth = "_parse_${key}_attr"; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 110954 | ▶ | if ( my $code = $self->can($meth) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 42506 | my %new_attrs = $self->$code( $c, $name, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 483 | 42506 | ▶ | while (my ($new_key, $value) = each %new_attrs){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 42740 | ▶ | my $new_attrs = $key eq $new_key ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | { $new_key => [$value] } : | ||||||||||||||||||||||||||||||||||||||||||
| 486 | $self->_parse_attr($c, $name, $new_key => $value ); | ||||||||||||||||||||||||||||||||||||||||||
| 487 | 42740 | push @{ $final_attributes{$_} }, @{ $new_attrs->{$_} } for keys %$new_attrs; | |||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 491 | 68448 | push( @{ $final_attributes{$key} }, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 107755 | return \%final_attributes; | |||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 1716 | ▶ | sub _parse_Global_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_Global_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 1716 | my ( $self, $c, $name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 500 | # _parse_attr will call _parse_Path_attr for us | ||||||||||||||||||||||||||||||||||||||||||
| 501 | 1716 | return Path => "/$name"; | |||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | 78 | ▶ | sub _parse_Absolute_attr { shift->_parse_Global_attr(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_Absolute_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 11053 | ▶ | sub _parse_Local_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_Local_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 11053 | my ( $self, $c, $name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 508 | # _parse_attr will call _parse_Path_attr for us | ||||||||||||||||||||||||||||||||||||||||||
| 509 | 11053 | return Path => $name; | |||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 1950 | ▶ | sub _parse_Relative_attr { shift->_parse_Local_attr(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_Relative_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 14844 | ▶ | sub _parse_Path_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_Path_attr: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 14844 | my ( $self, $c, $name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 516 | 14844 | ▶ | $value = '' if !defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 14844 | ▶ | if ( $value =~ m!^/! ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 2113 | return ( 'Path', $value ); | |||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 520 | elsif ( length $value ) { | ||||||||||||||||||||||||||||||||||||||||||
| 521 | 12162 | return ( 'Path', join( '/', $self->path_prefix($c), $value ) ); | |||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||
| 523 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 524 | 569 | return ( 'Path', $self->path_prefix($c) ); | |||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | 11679 | ▶ | sub _parse_Chained_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_Chained_attr: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | 11679 | my ($self, $c, $name, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 11679 | ▶ | if (defined($value) && length($value)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $value and length $value
MC/DC50%1/2
defined $value and length $value
defined $value
length $value
Truth table66%2/3
A and B
A= defined $valueB= length $value
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 10820 | ▶ | if ($value eq '.') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 312 | $value = '/'.$self->action_namespace($c); | |||||||||||||||||||||||||||||||||||||||||
| 534 | } elsif (my ($rel, $rest) = $value =~ /^((?:\.{2}\/)+)(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 535 | 312 | my @parts = split '/', $self->action_namespace($c); | |||||||||||||||||||||||||||||||||||||||||
| 536 | 312 | my @levels = split '/', $rel; | |||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | 312 | $value = '/'.join('/', @parts[0 .. $#parts - @levels], $rest); | |||||||||||||||||||||||||||||||||||||||||
| 539 | } elsif ($value !~ m/^\//) { | ||||||||||||||||||||||||||||||||||||||||||
| 540 | 6184 | my $action_ns = $self->action_namespace($c); | |||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | 6184 | ▶ | if ($action_ns) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | 6037 | $value = '/'.join('/', $action_ns, $value); | |||||||||||||||||||||||||||||||||||||||||
| 544 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 147 | $value = '/'.$value; # special case namespace '' (root) | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 859 | $value = '/' | |||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 11679 | return Chained => $value; | |||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 78 | ▶ | sub _parse_ChainedParent_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_ChainedParent_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 78 | my ($self, $c, $name, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 557 | 78 | return $self->_parse_Chained_attr($c, $name, '../'.$name); | |||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 316 | ▶ | sub _parse_PathPrefix_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_PathPrefix_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 316 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 562 | 316 | return PathPart => $self->path_prefix($c); | |||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 858 | ▶ | sub _parse_ActionClass_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_ActionClass_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | 858 | my ( $self, $c, $name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 567 | 858 | my $appname = $self->_application; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 858 | $value = Catalyst::Utils::resolve_namespace($appname . '::Action', $self->_action_class, $value); | |||||||||||||||||||||||||||||||||||||||||
| 569 | 858 | return ( 'ActionClass', $value ); | |||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 78 | ▶ | sub _parse_MyAction_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_MyAction_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 573 | 78 | my ( $self, $c, $name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 78 | my $appclass = Catalyst::Utils::class2appclass($self); | |||||||||||||||||||||||||||||||||||||||||
| 576 | 78 | $value = "+${appclass}::Action::${value}"; | |||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | 78 | return ( 'ActionClass', $value ); | |||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | 468 | ▶ | sub _parse_Does_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_Does_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | 468 | my ($self, $app, $name, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 583 | 468 | return Does => $self->_expand_role_shortname($value); | |||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | 318 | ▶ | sub _parse_GET_attr { Method => 'GET' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_GET_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 587 | 317 | ▶ | sub _parse_POST_attr { Method => 'POST' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_POST_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 588 | 235 | ▶ | sub _parse_PUT_attr { Method => 'PUT' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_PUT_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | 234 | ▶ | sub _parse_DELETE_attr { Method => 'DELETE' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_DELETE_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | 78 | ▶ | sub _parse_OPTIONS_attr { Method => 'OPTIONS' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_OPTIONS_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | sub _parse_HEAD_attr { Method => 'HEAD' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_HEAD_attr: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | sub _parse_PATCH_attr { Method => 'PATCH' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_PATCH_attr: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | 7481 | ▶ | sub _expand_role_shortname { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_role_shortname: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | 7481 | my ($self, @shortnames) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 596 | 7481 | my $app = $self->_application; | |||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | 7481 | ▶ | my $prefix = $self->can('_action_role_prefix') ? $self->_action_role_prefix : ['Catalyst::ActionRole::']; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | 7481 | my @prefixes = (qq{${app}::ActionRole::}, @$prefix); | |||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | return String::RewritePrefix->rewrite( | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 312 | ▶ | { '' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | my $loaded = load_first_existing_class( | ||||||||||||||||||||||||||||||||||||||||||
| 604 | 312 | map { "$_$_[0]" } @prefixes | |||||||||||||||||||||||||||||||||||||||||
| 605 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 606 | 546 | ▶ | return first { $loaded =~ /^$_/ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | 312 | sort { length $b <=> length $a } @prefixes; | |||||||||||||||||||||||||||||||||||||||||
| 608 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 609 | 7481 | '~' => $prefixes[0], | |||||||||||||||||||||||||||||||||||||||||
| 610 | '+' => '' }, | ||||||||||||||||||||||||||||||||||||||||||
| 611 | @shortnames, | ||||||||||||||||||||||||||||||||||||||||||
| 612 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 166 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | 166 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | __END__ | ||||||||||||||||||||||||||||||||||||||||||