Declare/Controller/Meta/TypeConstraintMapping.pm

filter: Statementstmt 50.5% 43 / 85 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 62.0% 18 / 29 Podpod n/a totaltotal 47.2% 61 / 129 CC 10 SCAR 15.9
CC
10
Cov
44%
__ANON__
17.3
__ANON__
9.6
__ANON__
9.6
CRAP 4.9
« Declare/Controller/DetermineActionClass.pm ↑ Summary Declare/DefaultSuperclassing.pm »
1 15 ▶use MooseX::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 15 ▶role CatalystX::Declare::Controller::Meta::TypeConstraintMapping {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=1.9
4  
5 15 ▶ use MooseX::Types::Moose qw( HashRef Object ArrayRef Str CodeRef );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 15 ▶ use aliased 'Moose::Meta::TypeConstraint';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 ▶ use aliased 'MooseX::Method::Signatures::Meta::Method', 'MethodWithSignature';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 15 has method_type_constraint_map => (
11 traits => [ 'Hash' ],
12 is => 'ro',
13 isa => HashRef[Object],
14 required => 1,
15 lazy_build => 1,
16 handles => {
17 'get_method_type_constraint' => 'get',
18 'set_method_type_constraint' => 'set',
19 },
20 );
21  
22 15 has method_named_param_map => (
23 traits => [ 'Hash' ],
24 is => 'ro',
25 isa => HashRef[ArrayRef[Str]],
26 required => 1,
27 lazy_build => 1,
28 handles => {
29 'get_method_named_params' => 'get',
30 'set_method_named_params' => 'set',
31 },
32 );
33  
34 15 has method_named_type_constraint_map => (
35 traits => [ 'Hash' ],
36 is => 'ro',
37 isa => HashRef[HashRef[Object]],
38 required => 1,
39 lazy_build => 1,
40 handles => {
41 'get_method_named_type_constraint' => 'get',
42 'set_method_named_type_constraint' => 'set',
43 },
44 );
45  
46 0 ▶ method _build_method_type_constraint_map {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=2.6
47 0 return +{};
48 15 }
49  
50 0 ▶ method _build_method_named_type_constraint_map {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=2.6
51 0 return +{};
52 15 }
53  
54 0 ▶ method _build_method_named_param_map {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=2.6
55 0 return +{};
56 15 }
57  
58 0 ▶ around add_method ($method_name, $method) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=4 SCAR=28.5
59  
60 0 ▶ if (is_Object $method and $method->isa(MethodWithSignature)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_Object($method) and $method->isa("MooseX::Method::Signatures::Meta::Method")) 0 0 0
Condition0%0/3
is_Object($method) and $method->isa("MooseX::Method::Signatures::Meta::Method")
!ll&&!rl&&r
000
MC/DC0%0/2
is_Object($method) and $method->isa("MooseX::Method::Signatures::Meta::Method")
is_Object($method) $method->isa("MooseX::Method::Signatures::Meta::Method")
Truth table0%0/3
A and B
A= is_Object($method)B= $method->isa("MooseX::Method::Signatures::Meta::Method")
ABresult
0X0
100
111
61  
62 0 my $tc = $method->type_constraint;
63  
64 0 $self->set_method_type_constraint(
65 $method_name,
66 $tc,
67 );
68  
69 0 ▶ if ($method->parsed_signature->has_named_params) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method->parsed_signature->has_named_params) 0 0 0
70 0 my $named = $method->parsed_signature->named_params;
71  
72 0 $self->set_method_named_params(
73 $method_name,
74 [ map $_->label, @$named ],
75 );
76 0 $self->set_method_named_type_constraint(
77 $method_name,
78 { map +($_->label, $_->meta_type_constraint), @$named },
79 );
80 }
81 }
82  
83 0 return $self->$orig($method_name, $method);
84 15 }
85  
86 0 ▶ method _find_capable_classes (CodeRef $test) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=4.9
87  
88 return
89 0 grep { local $_ = $_; $_->$test }
90 $self,
91 0 map { $_->meta }
92 0 grep { $_->can('meta') }
93 $self->linearized_isa;
94 15 }
95  
96 0 ▶ method find_method_named_params (Str $name) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=3 SCAR=22.6
97  
98 0 ▶ my @parents = $self->_find_capable_classes(sub { $_->can('get_method_named_params') });
Subroutine __ANON__: not called CC=1 SCAR=6.9
99  
100 0 for my $isa (@parents) {
101  
102 0 ▶ if (my $named = $isa->get_method_named_params($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $named = $isa->get_method_named_params($name)) 0 0 0
103 0 return [@$named];
104 }
105 }
106  
107 0 return undef;
108 15 }
109  
110 0 ▶ method find_method_named_type_constraint (Str $method, Str $param) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=3 SCAR=22.6
111  
112 0 ▶ my @parents = $self->_find_capable_classes(sub { $_->can('get_method_named_type_constraint') });
Subroutine __ANON__: not called CC=1 SCAR=6.9
113  
114 0 for my $isa (@parents) {
115  
116 0 ▶ if (my $named = $isa->get_method_named_type_constraint($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $named = $isa->get_method_named_type_constraint($method)) 0 0 0
117 0 return $named->{ $param };
118 }
119 }
120  
121 0 return undef;
122 15 }
123  
124 0 ▶ method find_method_type_constraint (Str $name) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=3 SCAR=22.6
125  
126 0 ▶ my @parents = $self->_find_capable_classes(sub { $_->can('get_method_type_constraint') });
Subroutine __ANON__: not called CC=1 SCAR=6.9
127  
128 0 for my $isa (@parents) {
129
130 0 ▶ if (my $tc = $isa->get_method_type_constraint($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tc = $isa->get_method_type_constraint($name)) 0 0 0
131 0 return $tc;
132 }
133 }
134  
135 0 return undef;
136 15 }
137 15 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
138  
« Declare/Controller/DetermineActionClass.pm ↑ Summary Declare/DefaultSuperclassing.pm »