blib/lib/Mouse/Tiny.pm

filter: Statementstmt 36.5% 854 / 2340 Branchbran 19.3% 188 / 970 Conditioncond 10.9% 48 / 440 MC/DCmcdc 0.3% 1 / 263 Subroutinesub 37.2% 173 / 464 Podpod 25.0% 63 / 252 totaltotal 28.0% 1327 / 4729 CC 711 SCAR 43.9
CC
711
Cov
29%
create
923.9
_process_options
765.4
_generate_accessor_any
184.2
CRAP 80.3
« blib/lib/Mouse/PurePerl.pm ↑ Summary blib/lib/Mouse/Util/MetaRole.pm »
1 # This file was generated by tool/generate-mouse-tiny.pl from Mouse v2.6.2.
2 #
3 # ANY CHANGES MADE HERE WILL BE LOST!
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # if regular Mouse is loaded, bail out
7 2 ▶unless ($INC{'Mouse.pm'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($INC{"Mouse.pm"}) 2 0 2
8 # tell Perl we already have all of the Mouse files loaded:
9 2 $INC{'Mouse.pm'} = __FILE__;
10 2 $INC{'Mouse/Exporter.pm'} = __FILE__;
11 2 $INC{'Mouse/Meta/Attribute.pm'} = __FILE__;
12 2 $INC{'Mouse/Meta/Class.pm'} = __FILE__;
13 2 $INC{'Mouse/Meta/Method.pm'} = __FILE__;
14 2 $INC{'Mouse/Meta/Method/Accessor.pm'} = __FILE__;
15 2 $INC{'Mouse/Meta/Method/Constructor.pm'} = __FILE__;
16 2 $INC{'Mouse/Meta/Method/Delegation.pm'} = __FILE__;
17 2 $INC{'Mouse/Meta/Method/Destructor.pm'} = __FILE__;
18 2 $INC{'Mouse/Meta/Module.pm'} = __FILE__;
19 2 $INC{'Mouse/Meta/Role.pm'} = __FILE__;
20 2 $INC{'Mouse/Meta/Role/Application.pm'} = __FILE__;
21 2 $INC{'Mouse/Meta/Role/Composite.pm'} = __FILE__;
22 2 $INC{'Mouse/Meta/Role/Method.pm'} = __FILE__;
23 2 $INC{'Mouse/Meta/TypeConstraint.pm'} = __FILE__;
24 2 $INC{'Mouse/Object.pm'} = __FILE__;
25 2 $INC{'Mouse/PurePerl.pm'} = __FILE__;
26 2 $INC{'Mouse/Role.pm'} = __FILE__;
27 2 $INC{'Mouse/Util.pm'} = __FILE__;
28 2 $INC{'Mouse/Util/MetaRole.pm'} = __FILE__;
29 2 $INC{'Mouse/Util/TypeConstraints.pm'} = __FILE__;
30 2 eval sprintf("#line %d %s\n", __LINE__, __FILE__) . <<'END_OF_TINY';
31  
32 # and now their contents
33 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=2.3
34 BEGIN{ # lib/Mouse/PurePerl.pm
35 package Mouse::PurePerl;
36 # The pure Perl backend for Mouse
37 4 ▶package Mouse::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 use warnings FATAL => 'redefine'; # to avoid to load Mouse::PurePerl twice
41 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
42 2 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
43 use B ();
44 2  
45 require Mouse::Util;
46  
47 8 ▶# taken from Class/MOP.pm
Subroutine is_valid_class_name: called CC=4 SCAR=15.6
Pod undocumented
48 8 sub is_valid_class_name {
49 my $class = shift;
50 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 8 8
51 8 ▶ return 0 if ref($class);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $class 0 8 8
52 return 0 unless defined($class);
53 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $class =~ /\A \w+ (?: :: \w+ )* \z/msx 8 0 8
54 return 1 if $class =~ /\A \w+ (?: :: \w+ )* \z/xms;
55 0  
56 return 0;
57 }
58 8 ▶ 
Subroutine is_class_loaded: called CC=17 SCAR=36.0
Pod documented
59 8 sub is_class_loaded {
60 my $class = shift;
61 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ref $class or not defined $class or not length $class 0 8 8
Condition33%2/6
ref $class or not defined $class or not length $class
l!l&&r!l&&!r
008
ref $class or not defined $class
l!l&&r!l&&!r
008
MC/DC0%0/3
ref $class or not defined $class or not length $class
ref $class not defined $class not length $class
Truth table25%1/4
A or not(B) or not(C)
A= ref $classB= not defined $classC= not length $class
ABCresult
1XX1
01X1
0011
0000
62 return 0 if ref($class) || !defined($class) || !length($class);
63  
64 # walk the symbol table tree to avoid autovififying
65 # \*{${main::}{"Foo::"}{"Bar::"}} == \*main::Foo::Bar::
66 8  
67 8 my $pack = \%::;
68 24 foreach my $part (split('::', $class)) {
69 24 ▶ $part .= '::';
Branch: 1 branch
BranchTrueFalseTotal
unless exists $pack->{$part} 0 24 24
70 return 0 if !exists $pack->{$part};
71 24  
72 24 ▶ my $entry = \$pack->{$part};
Branch: 1 branch
BranchTrueFalseTotal
if ref $entry ne "GLOB" 0 24 24
73 24 return 0 if ref($entry) ne 'GLOB';
74 $pack = *{$entry}{HASH};
75 }
76 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless %{$pack;} 0 8 8
77 return 0 if !%{$pack};
78  
79 # check for $VERSION or @ISA
80 0 ▶ return 1 if exists $pack->{VERSION}
Branch: 1 branch
BranchTrueFalseTotal
if exists $pack->{"VERSION"} and defined *{$pack->{"VERSION"};}{"SCALAR"} and defined ${$$pack{"VERSION"};} 0 8 8
Condition33%2/6
exists $pack->{"VERSION"} and defined *{$pack->{"VERSION"};}{"SCALAR"} and defined ${$$pack{"VERSION"};}
!ll&&!rl&&r
800
exists $pack->{"VERSION"} and defined *{$pack->{"VERSION"};}{"SCALAR"}
!ll&&!rl&&r
800
MC/DC0%0/3
exists $pack->{"VERSION"} and defined *{$pack->{"VERSION"};}{"SCALAR"} and defined ${$$pack{"VERSION"};}
exists $pack->{"VERSION"} defined *{$pack->{"VERSION"};}{"SCALAR"} defined ${$$pack{"VERSION"};}
Truth table25%1/4
A and B and C
A= exists $pack->{"VERSION"}B= defined *{$pack->{"VERSION"};}{"SCALAR"}C= defined ${$$pack{"VERSION"};}
ABCresult
0XX0
10X0
1100
1111
81 && defined *{$pack->{VERSION}}{SCALAR} && defined ${ $pack->{VERSION} };
82 0 ▶ return 1 if exists $pack->{ISA}
Branch: 1 branch
BranchTrueFalseTotal
if exists $pack->{"ISA"} and defined *{$pack->{"ISA"};}{"ARRAY"} and @{$pack->{"ISA"};} != 0 0 8 8
Condition33%2/6
exists $pack->{"ISA"} and defined *{$pack->{"ISA"};}{"ARRAY"} and @{$pack->{"ISA"};} != 0
!ll&&!rl&&r
800
exists $pack->{"ISA"} and defined *{$pack->{"ISA"};}{"ARRAY"}
!ll&&!rl&&r
800
MC/DC0%0/3
exists $pack->{"ISA"} and defined *{$pack->{"ISA"};}{"ARRAY"} and @{$pack->{"ISA"};} != 0
exists $pack->{"ISA"} defined *{$pack->{"ISA"};}{"ARRAY"} @{$pack->{"ISA"};} != 0
Truth table25%1/4
A and B and C
A= exists $pack->{"ISA"}B= defined *{$pack->{"ISA"};}{"ARRAY"}C= @{$pack->{"ISA"};} != 0
ABCresult
0XX0
10X0
1100
1111
83 && defined *{$pack->{ISA}}{ARRAY} && @{ $pack->{ISA} } != 0;
84  
85 8 # check for any method
86 9 foreach my $name( keys %{$pack} ) {
87 9 ▶ my $entry = \$pack->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if ref $entry ne "GLOB" or defined *{$entry;}{"CODE"} 8 1 9
Condition66%2/3
ref $entry ne "GLOB" or defined *{$entry;}{"CODE"}
l!l&&r!l&&!r
081
MC/DC50%1/2
ref $entry ne "GLOB" or defined *{$entry;}{"CODE"}
ref $entry ne "GLOB" defined *{$entry;}{"CODE"}
Truth table66%2/3
A or B
A= ref $entry ne "GLOB"B= defined *{$entry;}{"CODE"}
ABresult
1X1
011
000
88 return 1 if ref($entry) ne 'GLOB' || defined *{$entry}{CODE};
89 }
90  
91 0 # fail
92 return 0;
93 }
94  
95  
96 12 ▶# taken from Sub::Identify
Subroutine get_code_info: called CC=4 SCAR=14.3
Pod documented
97 12 sub get_code_info {
98 12 ▶ my ($coderef) = @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $coderef or return 12 0 12
99 ref($coderef) or return;
100 12  
101 12 ▶ my $cv = B::svref_2object($coderef);
Branch: 1 branch
BranchTrueFalseTotal
$cv->isa("B::CV") or return 12 0 12
102 $cv->isa('B::CV') or return;
103 12  
104 12 ▶ my $gv = $cv->GV;
Branch: 1 branch
BranchTrueFalseTotal
$gv->isa("B::GV") or return 12 0 12
105 $gv->isa('B::GV') or return;
106 12  
107 return ($gv->STASH->NAME, $gv->NAME);
108 }
109 0 ▶ 
Subroutine get_code_package: not called CC=3 SCAR=24.8
Pod documented
110 0 sub get_code_package{
111 my($coderef) = @_;
112 0  
113 0 ▶ my $cv = B::svref_2object($coderef);
Branch: 1 branch
BranchTrueFalseTotal
$cv->isa("B::CV") or return "" 0 0 0
114 $cv->isa('B::CV') or return '';
115 0  
116 0 ▶ my $gv = $cv->GV;
Branch: 1 branch
BranchTrueFalseTotal
$gv->isa("B::GV") or return "" 0 0 0
117 $gv->isa('B::GV') or return '';
118 0  
119 return $gv->STASH->NAME;
120 }
121 0 ▶ 
Subroutine get_code_ref: not called CC=1 SCAR=0.2
Pod documented
122 0 sub get_code_ref{
123 2 ▶ my($package, $name) = @_;
Subroutine BEGIN: called CC=1 SCAR=0.0
124 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
125 2 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
126 0 use warnings FATAL => 'uninitialized';
127 return *{$package . '::' . $name}{CODE};
128 }
129 4 ▶ 
Subroutine generate_isa_predicate_for: called CC=2 SCAR=9.7
Pod undocumented
130 4 sub generate_isa_predicate_for {
131 my($for_class, $name) = @_;
132 0 ▶ 
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_[0]) and $_[0]->isa($for_class) 0 0 0
133 my $predicate = sub{ Scalar::Util::blessed($_[0]) && $_[0]->isa($for_class) };
134 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) 0 4 4
135 0 if(defined $name){
136 0 Mouse::Util::install_subroutines(scalar caller, $name => $predicate);
137 return;
138 }
139 4  
140 return $predicate;
141 }
142 6 ▶ 
Subroutine generate_can_predicate_for: called CC=2 SCAR=8.4
Pod undocumented
143 6 sub generate_can_predicate_for {
144 my($methods_ref, $name) = @_;
145 6  
146 my @methods = @{$methods_ref};
147 8 ▶ 
Subroutine __ANON__: called CC=4 SCAR=20.9
148 8 my $predicate = sub{
149 8 ▶ my($instance) = @_;
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($instance)) 0 8 8
150 0 if(Scalar::Util::blessed($instance)){
151 0 ▶ foreach my $method(@methods){
Branch: 1 branch
BranchTrueFalseTotal
unless ($instance->can($method)) 0 0 0
152 0 if(!$instance->can($method)){
153 return 0;
154 }
155 0 }
156 return 1;
157 8 }
158 6 return 0;
159 };
160 6 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) 6 0 6
161 6 if(defined $name){
162 6 Mouse::Util::install_subroutines(scalar caller, $name => $predicate);
163 return;
164 }
165 0  
166 return $predicate;
167 }
168  
169 package Mouse::Util::TypeConstraints;
170  
171 0 ▶ 
Subroutine Any: not called CC=1 SCAR=6.9
Pod undocumented
172 0 ▶sub Any { 1 }
Subroutine Item: not called CC=1 SCAR=6.9
Pod undocumented
173 sub Item { 1 }
174 0 ▶ 
Subroutine Bool: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
not $_[0] or $_[0] eq 1 0 0 0
175 0 ▶sub Bool { !$_[0] || $_[0] eq '1' }
Subroutine Undef: not called CC=1 SCAR=6.9
Pod undocumented
176 0 ▶sub Undef { !defined($_[0]) }
Subroutine Defined: not called CC=1 SCAR=6.9
Pod undocumented
177 0 ▶sub Defined { defined($_[0]) }
Subroutine Value: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] and not ref $_[0] 0 0 0
178 0 ▶sub Value { defined($_[0]) && !ref($_[0]) }
Subroutine Num: not called CC=1 SCAR=6.9
Pod undocumented
179 0 ▶sub Num { Scalar::Util::looks_like_number($_[0]) }
Subroutine Str: not called CC=2 SCAR=17.9
Pod undocumented
180 sub Str {
181 # We need to use a copy here to flatten MAGICs, for instance as in
182 0 # Str( substr($_, 0, 42) ).
183 0 ▶ my($value) = @_;
Condition0%0/3
defined $value && ref \$value eq 'SCALAR'
!ll&&!rl&&r
000
MC/DC0%0/2
defined $value && ref \$value eq 'SCALAR'
defined $value ref \$value eq 'SCALAR'
Truth table0%0/3
A && B
A= defined $valueB= ref \$value eq 'SCALAR'
ABresult
0X0
100
111
184 return defined($value) && ref(\$value) eq 'SCALAR';
185 0 ▶}
Subroutine Int: not called CC=2 SCAR=17.9
Pod undocumented
186 sub Int {
187 0 # We need to use a copy here to save the original internal SV flags.
188 0 ▶ my($value) = @_;
Condition0%0/3
defined $value && $value =~ /\A -? [0-9]+ \z/msx
!ll&&!rl&&r
000
MC/DC0%0/2
defined $value && $value =~ /\A -? [0-9]+ \z/msx
defined $value $value =~ /\A -? [0-9]+ \z/msx
Truth table0%0/3
A && B
A= defined $valueB= $value =~ /\A -? [0-9]+ \z/msx
ABresult
0X0
100
111
189 return defined($value) && $value =~ /\A -? [0-9]+ \z/xms;
190 }
191 0 ▶ 
Subroutine Ref: not called CC=1 SCAR=6.9
Pod undocumented
192 0 ▶sub Ref { ref($_[0]) }
Subroutine ScalarRef: not called CC=2 SCAR=17.9
Pod undocumented
193 0 sub ScalarRef {
194 0 ▶ my($value) = @_;
Condition0%0/3
ref $value eq 'SCALAR' || ref $value eq 'REF'
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $value eq 'SCALAR' || ref $value eq 'REF'
ref $value eq 'SCALAR' ref $value eq 'REF'
Truth table0%0/3
A || B
A= ref $value eq 'SCALAR'B= ref $value eq 'REF'
ABresult
1X1
011
000
195 return ref($value) eq 'SCALAR' || ref($value) eq 'REF';
196 0 ▶}
Subroutine ArrayRef: not called CC=1 SCAR=6.9
Pod undocumented
197 0 ▶sub ArrayRef { ref($_[0]) eq 'ARRAY' }
Subroutine HashRef: not called CC=1 SCAR=6.9
Pod undocumented
198 0 ▶sub HashRef { ref($_[0]) eq 'HASH' }
Subroutine CodeRef: not called CC=1 SCAR=6.9
Pod undocumented
199 0 ▶sub CodeRef { ref($_[0]) eq 'CODE' }
Subroutine RegexpRef: not called CC=1 SCAR=6.9
Pod undocumented
200 0 ▶sub RegexpRef { ref($_[0]) eq 'Regexp' }
Subroutine GlobRef: not called CC=1 SCAR=6.9
Pod undocumented
201 sub GlobRef { ref($_[0]) eq 'GLOB' }
202 0 ▶ 
Subroutine FileHandle: not called CC=3 SCAR=24.8
Pod undocumented
203 0 sub FileHandle {
204 0 ▶ my($value) = @_;
Condition0%0/6
&Scalar::Util::openhandle($value) || builtin::blessed($value) && $value->isa('IO::Handle')
l!l&&r!l&&!r
000
builtin::blessed($value) and $value->isa("IO::Handle")
!ll&&!rl&&r
000
MC/DC0%0/3
&Scalar::Util::openhandle($value) || builtin::blessed($value) && $value->isa('IO::Handle')
&Scalar::Util::openhandle($value) builtin::blessed($value) $value->isa("IO::Handle")
Truth table0%0/4
A || B and C
A= &Scalar::Util::openhandle($value)B= builtin::blessed($value)C= $value->isa("IO::Handle")
ABCresult
1XX1
0111
00X0
0100
205 return Scalar::Util::openhandle($value)
206 || (Scalar::Util::blessed($value) && $value->isa("IO::Handle"))
207 }
208 0 ▶ 
Subroutine Object: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_[0]) and ref $_[0] ne "Regexp" 0 0 0
209 sub Object { Scalar::Util::blessed($_[0]) && ref($_[0]) ne 'Regexp' }
210 0 ▶ 
Subroutine ClassName: not called CC=1 SCAR=6.9
Pod undocumented
211 0 ▶sub ClassName { Mouse::Util::is_class_loaded($_[0]) }
Subroutine RoleName: not called CC=2 SCAR=17.9
Pod undocumented
Condition0%0/2
Mouse::Util::class_of($_[0]) || (return 0)
l!l
00
MC/DC0%0/1
Mouse::Util::class_of($_[0]) || (return 0)
Mouse::Util::class_of($_[0])
Truth table0%0/2
A
A= Mouse::Util::class_of($_[0])
Aresult
11
00
212 sub RoleName { (Mouse::Util::class_of($_[0]) || return 0)->isa('Mouse::Meta::Role') }
213 0 ▶ 
Subroutine _parameterize_ArrayRef_for: not called CC=1 SCAR=6.9
214 0 sub _parameterize_ArrayRef_for {
215 0 my($type_parameter) = @_;
216 my $check = $type_parameter->_compiled_type_constraint;
217 0 ▶ 
Subroutine __ANON__: not called CC=3 SCAR=24.8
218 0 return sub {
219 0 ▶ foreach my $value (@{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
unless &$check($value) 0 0 0
220 return undef unless $check->($value);
221 0 }
222 return 1;
223 0 }
224 }
225 0 ▶ 
Subroutine _parameterize_HashRef_for: not called CC=1 SCAR=6.9
226 0 sub _parameterize_HashRef_for {
227 0 my($type_parameter) = @_;
228 my $check = $type_parameter->_compiled_type_constraint;
229 0 ▶ 
Subroutine __ANON__: not called CC=3 SCAR=24.8
230 0 return sub {
231 0 ▶ foreach my $value(values %{$_}){
Branch: 1 branch
BranchTrueFalseTotal
unless &$check($value) 0 0 0
232 return undef unless $check->($value);
233 0 }
234 0 return 1;
235 };
236 }
237  
238 0 ▶# 'Maybe' type accepts 'Any', so it requires parameters
Subroutine _parameterize_Maybe_for: not called CC=1 SCAR=6.9
239 0 sub _parameterize_Maybe_for {
240 0 my($type_parameter) = @_;
241 my $check = $type_parameter->_compiled_type_constraint;
242 0 ▶ 
Subroutine __ANON__: not called CC=2 SCAR=17.9
243 0 ▶ return sub{
Condition0%0/3
!defined($_) || &$check($_)
l!l&&r!l&&!r
000
MC/DC0%0/2
!defined($_) || &$check($_)
!defined($_) &$check($_)
Truth table0%0/3
not(A) || B
A= !defined($_)B= &$check($_)
ABresult
1X1
011
000
244 0 return !defined($_) || $check->($_);
245 };
246 }
247  
248 package Mouse::Meta::Module;
249 24 ▶ 
Subroutine name: called CC=1 SCAR=0.0
Pod undocumented
250 sub name { $_[0]->{package} }
251 0 ▶ 
Subroutine _method_map: not called CC=1 SCAR=6.9
252 0 ▶sub _method_map { $_[0]->{methods} }
Subroutine _attribute_map: not called CC=1 SCAR=6.9
253 sub _attribute_map{ $_[0]->{attributes} }
254 0 ▶ 
Subroutine namespace: not called CC=1 SCAR=1.2
Pod undocumented
255 0 sub namespace{
256 4 ▶ my $name = $_[0]->{package};
Subroutine BEGIN: called CC=1 SCAR=0.0
257 0 no strict 'refs';
258 return \%{ $name . '::' };
259 }
260 8 ▶ 
Subroutine add_method: called CC=4 SCAR=16.3
Pod undocumented
261 8 sub add_method {
262 my($self, $name, $code) = @_;
263 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 0 8 8
264 0 if(!defined $name){
265 $self->throw_error('You must pass a defined name');
266 8 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $code) 0 8 8
267 0 if(!defined $code){
268 $self->throw_error('You must pass a defined code');
269 }
270 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (ref $code ne "CODE") 0 8 8
271 0 if(ref($code) ne 'CODE'){
272 $code = \&{$code}; # coerce
273 }
274 8  
275 $self->{methods}->{$name} = $code; # Moose stores meta object here.
276 8  
277 Mouse::Util::install_subroutines($self->name,
278 $name => $code,
279 8 );
280 return;
281 }
282 2 ▶ 
Subroutine __ANON__: called CC=1 SCAR=0.2
283 2 my $generate_class_accessor = sub {
284 4 ▶ my($name) = @_;
Subroutine __ANON__: called CC=5 SCAR=17.2
285 4 return sub {
286 4 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 4 4
287 0 if(@_) {
288 return $self->{$name} = shift;
289 }
290 4  
291 8 ▶ foreach my $class($self->linearized_isa) {
Branch: 1 branch
BranchTrueFalseTotal
my $meta = Mouse::Util::get_metaclass_by_name($class) or next 4 4 8
292 my $meta = Mouse::Util::get_metaclass_by_name($class)
293 or next;
294 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $meta->{$name}) 0 4 4
295 0 if(exists $meta->{$name}) {
296 return $meta->{$name};
297 }
298 4 }
299 2 return undef;
300 2 };
301 };
302  
303  
304 package Mouse::Meta::Class;
305 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
306 2 ▶use Mouse::Meta::Method::Constructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
307 use Mouse::Meta::Method::Destructor;
308 0 ▶ 
Subroutine method_metaclass: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"method_metaclass"} or "Mouse::Meta::Method" 0 0 0
309 4 ▶sub method_metaclass { $_[0]->{method_metaclass} || 'Mouse::Meta::Method' }
Subroutine attribute_metaclass: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"attribute_metaclass"} or "Mouse::Meta::Attribute" 0 4 4
310 sub attribute_metaclass { $_[0]->{attribute_metaclass} || 'Mouse::Meta::Attribute' }
311 4 ▶ 
Subroutine constructor_class: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"constructor_class"} or "Mouse::Meta::Method::Constructor" 0 4 4
312 0 ▶sub constructor_class { $_[0]->{constructor_class} || 'Mouse::Meta::Method::Constructor' }
Subroutine destructor_class: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"destructor_class"} or "Mouse::Meta::Method::Destructor" 0 0 0
313 sub destructor_class { $_[0]->{destructor_class} || 'Mouse::Meta::Method::Destructor' }
314 4 ▶ 
Subroutine is_anon_class: called CC=1 SCAR=0.0
Pod undocumented
315 4 sub is_anon_class{
316 return exists $_[0]->{anon_serial_id};
317 }
318 0 ▶ 
Subroutine roles: not called CC=1 SCAR=6.9
Pod undocumented
319 sub roles { $_[0]->{roles} }
320 8 ▶ 
Subroutine linearized_isa: called CC=1 SCAR=0.0
Pod documented
321 sub linearized_isa { @{ Mouse::Util::get_linear_isa($_[0]->{package}) } }
322 4 ▶ 
Subroutine new_object: called CC=5 SCAR=19.6
Pod documented
323 4 sub new_object {
324 4 ▶ my $meta = shift;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 4 0 4
325 my %args = (@_ == 1 ? %{$_[0]} : @_);
326 4  
327 my $object = bless {}, $meta->name;
328 4  
329 $meta->_initialize_object($object, \%args, 0);
330 4 ▶ # BUILDALL
Branch: 1 branch
BranchTrueFalseTotal
if ($object->can("BUILD")) 0 4 4
331 0 if( $object->can('BUILD') ) {
332 0 ▶ for my $class (reverse $meta->linearized_isa) {
Condition0%0/2
Mouse::Util::get_code_ref($class, 'BUILD') || (next)
l!l
00
MC/DC0%0/1
Mouse::Util::get_code_ref($class, 'BUILD') || (next)
Mouse::Util::get_code_ref($class, 'BUILD')
Truth table0%0/2
A
A= Mouse::Util::get_code_ref($class, 'BUILD')
Aresult
11
00
333 my $build = Mouse::Util::get_code_ref($class, 'BUILD')
334 || next;
335 0  
336 $object->$build(\%args);
337 }
338 4 }
339 return $object;
340 }
341 0 ▶ 
Subroutine clone_object: not called CC=3 SCAR=24.8
Pod documented
342 0 sub clone_object {
343 0 my $class = shift;
344 0 my $object = shift;
345 my $args = $object->Mouse::Object::BUILDARGS(@_);
346 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($object) and $object->isa($class->name) or $class->throw_error('You must pass an instance of the metaclass (' . $class->name . "), not ($object)") 0 0 0
Condition0%0/3
builtin::blessed($object) and $object->isa($class->name)
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($object) and $object->isa($class->name)
builtin::blessed($object) $object->isa($class->name)
Truth table0%0/3
A and B
A= builtin::blessed($object)B= $object->isa($class->name)
ABresult
0X0
100
111
347 (Scalar::Util::blessed($object) && $object->isa($class->name))
348 || $class->throw_error("You must pass an instance of the metaclass (" . $class->name . "), not ($object)");
349 0  
350 0 my $cloned = bless { %$object }, ref $object;
351 0 $class->_initialize_object($cloned, $args, 1);
352 return $cloned;
353 }
354 4 ▶ 
Subroutine _initialize_object: called CC=2 SCAR=7.4
355 4 sub _initialize_object{
356 my($self, $object, $args, $is_cloning) = @_;
357 # The initializer, which is used everywhere, must be clear
358 # when an attribute is added. See Mouse::Meta::Class::add_attribute.
359 4 ▶ my $initializer = $self->{_mouse_cache}{_initialize_object} ||=
Condition33%1/3
$self->{"_mouse_cache"}{"_initialize_object"} ||= Mouse::Util::load_class($self->constructor_class)->_generate_initialize_object($self)
l!l&&r!l&&!r
040
MC/DC0%0/2
$self->{"_mouse_cache"}{"_initialize_object"} ||= Mouse::Util::load_class($self->constructor_class)->_generate_initialize_object($self)
$self->{"_mouse_cache"}{"_initialize_object"} Mouse::Util::load_class($self->constructor_class)->_generate_initialize_object($self)
Truth table33%1/3
A ||= B
A= $self->{"_mouse_cache"}{"_initialize_object"}B= Mouse::Util::load_class($self->constructor_class)->_generate_initialize_object($self)
ABresult
1X1
011
000
360 Mouse::Util::load_class($self->constructor_class)
361 4 ->_generate_initialize_object($self);
362 goto &{$initializer};
363 }
364 4 ▶ 
Subroutine get_all_attributes: called CC=2 SCAR=7.6
Pod documented
365 4 sub get_all_attributes {
366 4 my($self) = @_;
367 4 ▶ return @{ $self->{_mouse_cache}{all_attributes}
Condition33%1/3
$self->{"_mouse_cache"}{"all_attributes"} ||= $self->_calculate_all_attributes
l!l&&r!l&&!r
040
MC/DC0%0/2
$self->{"_mouse_cache"}{"all_attributes"} ||= $self->_calculate_all_attributes
$self->{"_mouse_cache"}{"all_attributes"} $self->_calculate_all_attributes
Truth table33%1/3
A ||= B
A= $self->{"_mouse_cache"}{"all_attributes"}B= $self->_calculate_all_attributes
ABresult
1X1
011
000
368 ||= $self->_calculate_all_attributes };
369 }
370 0 ▶ 
Subroutine is_immutable: not called CC=1 SCAR=6.9
Pod undocumented
371 sub is_immutable { $_[0]->{is_immutable} }
372  
373 2 sub strict_constructor;
374 *strict_constructor = $generate_class_accessor->('strict_constructor');
375 4 ▶ 
Subroutine _invalidate_metaclass_cache: called CC=1 SCAR=0.0
376 4 sub _invalidate_metaclass_cache {
377 4 my($self) = @_;
378 4 delete $self->{_mouse_cache};
379 return;
380 }
381 0 ▶ 
Subroutine _report_unknown_args: not called CC=5 SCAR=34.0
382 0 sub _report_unknown_args {
383 my($metaclass, $attrs, $args) = @_;
384 0  
385 my @unknowns;
386 0 my %init_args;
387 0 foreach my $attr(@{$attrs}){
388 0 ▶ my $init_arg = $attr->init_arg;
Branch: 1 branch
BranchTrueFalseTotal
if (defined $init_arg) 0 0 0
389 0 if(defined $init_arg){
390 $init_args{$init_arg}++;
391 }
392 }
393 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $key = each %{$args;})) 0 0 0
394 0 ▶ while(my $key = each %{$args}){
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $init_args{$key}) 0 0 0
395 0 if(!exists $init_args{$key}){
396 push @unknowns, $key;
397 }
398 }
399 0  
400 $metaclass->throw_error( sprintf
401 "Unknown attribute passed to the constructor of %s: %s",
402 $metaclass->name, Mouse::Util::english_list(@unknowns),
403 );
404 }
405  
406 package Mouse::Meta::Role;
407 0 ▶ 
Subroutine method_metaclass: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"method_metaclass"} or "Mouse::Meta::Role::Method" 0 0 0
408 sub method_metaclass{ $_[0]->{method_metaclass} || 'Mouse::Meta::Role::Method' }
409 0 ▶ 
Subroutine is_anon_role: not called CC=1 SCAR=6.9
Pod undocumented
410 0 sub is_anon_role{
411 return exists $_[0]->{anon_serial_id};
412 }
413 0 ▶ 
Subroutine get_roles: not called CC=1 SCAR=6.9
Pod undocumented
414 sub get_roles { $_[0]->{roles} }
415 0 ▶ 
Subroutine add_before_method_modifier: not called CC=2 SCAR=17.9
Pod undocumented
416 0 sub add_before_method_modifier {
417 my ($self, $method_name, $method) = @_;
418 0 ▶ 
Condition0%0/2
$self->{"before_method_modifiers"}{$method_name} ||= []
l!l
00
MC/DC0%0/1
$self->{"before_method_modifiers"}{$method_name} ||= []
$self->{"before_method_modifiers"}{$method_name}
Truth table0%0/2
A
A= $self->{"before_method_modifiers"}{$method_name}
Aresult
11
00
419 0 push @{ $self->{before_method_modifiers}{$method_name} ||= [] }, $method;
420 return;
421 0 ▶}
Subroutine add_around_method_modifier: not called CC=2 SCAR=17.9
Pod undocumented
422 0 sub add_around_method_modifier {
423 my ($self, $method_name, $method) = @_;
424 0 ▶ 
Condition0%0/2
$self->{"around_method_modifiers"}{$method_name} ||= []
l!l
00
MC/DC0%0/1
$self->{"around_method_modifiers"}{$method_name} ||= []
$self->{"around_method_modifiers"}{$method_name}
Truth table0%0/2
A
A= $self->{"around_method_modifiers"}{$method_name}
Aresult
11
00
425 0 push @{ $self->{around_method_modifiers}{$method_name} ||= [] }, $method;
426 return;
427 0 ▶}
Subroutine add_after_method_modifier: not called CC=2 SCAR=17.9
Pod undocumented
428 0 sub add_after_method_modifier {
429 my ($self, $method_name, $method) = @_;
430 0 ▶ 
Condition0%0/2
$self->{"after_method_modifiers"}{$method_name} ||= []
l!l
00
MC/DC0%0/1
$self->{"after_method_modifiers"}{$method_name} ||= []
$self->{"after_method_modifiers"}{$method_name}
Truth table0%0/2
A
A= $self->{"after_method_modifiers"}{$method_name}
Aresult
11
00
431 0 push @{ $self->{after_method_modifiers}{$method_name} ||= [] }, $method;
432 return;
433 }
434 0 ▶ 
Subroutine get_before_method_modifiers: not called CC=2 SCAR=17.9
Pod undocumented
435 0 sub get_before_method_modifiers {
436 0 ▶ my ($self, $method_name) = @_;
Condition0%0/2
$self->{"before_method_modifiers"}{$method_name} ||= []
l!l
00
MC/DC0%0/1
$self->{"before_method_modifiers"}{$method_name} ||= []
$self->{"before_method_modifiers"}{$method_name}
Truth table0%0/2
A
A= $self->{"before_method_modifiers"}{$method_name}
Aresult
11
00
437 return @{ $self->{before_method_modifiers}{$method_name} ||= [] }
438 0 ▶}
Subroutine get_around_method_modifiers: not called CC=2 SCAR=17.9
Pod undocumented
439 0 sub get_around_method_modifiers {
440 0 ▶ my ($self, $method_name) = @_;
Condition0%0/2
$self->{"around_method_modifiers"}{$method_name} ||= []
l!l
00
MC/DC0%0/1
$self->{"around_method_modifiers"}{$method_name} ||= []
$self->{"around_method_modifiers"}{$method_name}
Truth table0%0/2
A
A= $self->{"around_method_modifiers"}{$method_name}
Aresult
11
00
441 return @{ $self->{around_method_modifiers}{$method_name} ||= [] }
442 0 ▶}
Subroutine get_after_method_modifiers: not called CC=2 SCAR=17.9
Pod undocumented
443 0 sub get_after_method_modifiers {
444 0 ▶ my ($self, $method_name) = @_;
Condition0%0/2
$self->{"after_method_modifiers"}{$method_name} ||= []
l!l
00
MC/DC0%0/1
$self->{"after_method_modifiers"}{$method_name} ||= []
$self->{"after_method_modifiers"}{$method_name}
Truth table0%0/2
A
A= $self->{"after_method_modifiers"}{$method_name}
Aresult
11
00
445 return @{ $self->{after_method_modifiers}{$method_name} ||= [] }
446 }
447 0 ▶ 
Subroutine add_metaclass_accessor: not called CC=1 SCAR=6.9
Pod undocumented
448 0 sub add_metaclass_accessor { # for meta roles (a.k.a. traits)
449 0 my($meta, $name) = @_;
450 0 $meta->add_method($name => $generate_class_accessor->($name));
451 return;
452 }
453  
454 package Mouse::Meta::Attribute;
455 2  
456 require Mouse::Meta::Method::Accessor;
457 4 ▶ 
Subroutine accessor_metaclass: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"accessor_metaclass"} or "Mouse::Meta::Method::Accessor" 0 4 4
458 sub accessor_metaclass{ $_[0]->{accessor_metaclass} || 'Mouse::Meta::Method::Accessor' }
459  
460 # readers
461 12 ▶ 
Subroutine name: called CC=1 SCAR=0.0
Pod undocumented
462 4 ▶sub name { $_[0]->{name} }
Subroutine associated_class: called CC=1 SCAR=0.0
Pod undocumented
463 sub associated_class { $_[0]->{associated_class} }
464 0 ▶ 
Subroutine accessor: not called CC=1 SCAR=6.9
Pod undocumented
465 0 ▶sub accessor { $_[0]->{accessor} }
Subroutine reader: not called CC=1 SCAR=6.9
Pod undocumented
466 0 ▶sub reader { $_[0]->{reader} }
Subroutine writer: not called CC=1 SCAR=6.9
Pod undocumented
467 0 ▶sub writer { $_[0]->{writer} }
Subroutine predicate: not called CC=1 SCAR=6.9
Pod undocumented
468 0 ▶sub predicate { $_[0]->{predicate} }
Subroutine clearer: not called CC=1 SCAR=6.9
Pod undocumented
469 0 ▶sub clearer { $_[0]->{clearer} }
Subroutine handles: not called CC=1 SCAR=6.9
Pod undocumented
470 sub handles { $_[0]->{handles} }
471 0 ▶ 
Subroutine _is_metadata: not called CC=1 SCAR=6.9
472 4 ▶sub _is_metadata { $_[0]->{is} }
Subroutine is_required: called CC=1 SCAR=0.0
Pod undocumented
473 4 ▶sub is_required { $_[0]->{required} }
Subroutine default: called CC=3 SCAR=12.0
Pod undocumented
474 4 sub default {
475 4 my($self, $instance) = @_;
476 4 ▶ my $value = $self->{default};
Branch: 1 branch
BranchTrueFalseTotal
if defined $instance and ref $value eq "CODE" 0 4 4
Condition33%1/3
defined $instance and ref $value eq "CODE"
!ll&&!rl&&r
400
MC/DC0%0/2
defined $instance and ref $value eq "CODE"
defined $instance ref $value eq "CODE"
Truth table33%1/3
A and B
A= defined $instanceB= ref $value eq "CODE"
ABresult
0X0
100
111
477 4 $value = $value->($instance) if defined($instance) and ref($value) eq "CODE";
478 return $value;
479 4 ▶}
Subroutine is_lazy: called CC=1 SCAR=0.0
Pod undocumented
480 0 ▶sub is_lazy { $_[0]->{lazy} }
Subroutine is_lazy_build: not called CC=1 SCAR=6.9
Pod undocumented
481 8 ▶sub is_lazy_build { $_[0]->{lazy_build} }
Subroutine is_weak_ref: called CC=1 SCAR=0.0
Pod undocumented
482 4 ▶sub is_weak_ref { $_[0]->{weak_ref} }
Subroutine init_arg: called CC=1 SCAR=0.0
Pod undocumented
483 12 ▶sub init_arg { $_[0]->{init_arg} }
Subroutine type_constraint: called CC=1 SCAR=0.0
Pod undocumented
484 sub type_constraint { $_[0]->{type_constraint} }
485 4 ▶ 
Subroutine trigger: called CC=1 SCAR=0.0
Pod documented
486 4 ▶sub trigger { $_[0]->{trigger} }
Subroutine builder: called CC=1 SCAR=0.0
Pod undocumented
487 4 ▶sub builder { $_[0]->{builder} }
Subroutine should_auto_deref: called CC=1 SCAR=0.0
Pod undocumented
488 0 ▶sub should_auto_deref { $_[0]->{auto_deref} }
Subroutine should_coerce: not called CC=1 SCAR=6.9
Pod undocumented
489 sub should_coerce { $_[0]->{coerce} }
490 0 ▶ 
Subroutine documentation: not called CC=1 SCAR=6.9
Pod undocumented
491 0 ▶sub documentation { $_[0]->{documentation} }
Subroutine insertion_order: not called CC=1 SCAR=6.9
Pod undocumented
492 sub insertion_order { $_[0]->{insertion_order} }
493  
494 # predicates
495 0 ▶ 
Subroutine has_accessor: not called CC=1 SCAR=6.9
Pod undocumented
496 0 ▶sub has_accessor { exists $_[0]->{accessor} }
Subroutine has_reader: not called CC=1 SCAR=6.9
Pod undocumented
497 0 ▶sub has_reader { exists $_[0]->{reader} }
Subroutine has_writer: not called CC=1 SCAR=6.9
Pod undocumented
498 0 ▶sub has_writer { exists $_[0]->{writer} }
Subroutine has_predicate: not called CC=1 SCAR=6.9
Pod undocumented
499 0 ▶sub has_predicate { exists $_[0]->{predicate} }
Subroutine has_clearer: not called CC=1 SCAR=6.9
Pod undocumented
500 0 ▶sub has_clearer { exists $_[0]->{clearer} }
Subroutine has_handles: not called CC=1 SCAR=6.9
Pod undocumented
501 sub has_handles { exists $_[0]->{handles} }
502 4 ▶ 
Subroutine has_default: called CC=1 SCAR=0.0
Pod undocumented
503 0 ▶sub has_default { exists $_[0]->{default} }
Subroutine has_type_constraint: not called CC=1 SCAR=6.9
Pod undocumented
504 4 ▶sub has_type_constraint { exists $_[0]->{type_constraint} }
Subroutine has_trigger: called CC=1 SCAR=0.0
Pod undocumented
505 4 ▶sub has_trigger { exists $_[0]->{trigger} }
Subroutine has_builder: called CC=1 SCAR=0.0
Pod undocumented
506 sub has_builder { exists $_[0]->{builder} }
507 0 ▶ 
Subroutine has_documentation: not called CC=1 SCAR=6.9
Pod undocumented
508 sub has_documentation { exists $_[0]->{documentation} }
509 4 ▶ 
Subroutine _process_options: called CC=43 SCAR=66.4
510 4 sub _process_options{
511 my($class, $name, $args) = @_;
512  
513 # taken from Class::MOP::Attribute::new
514 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
defined $name or $class->throw_error("You must provide a name for the attribute") 4 0 4
515 defined($name)
516 or $class->throw_error('You must provide a name for the attribute');
517 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args->{"init_arg"}) 4 0 4
518 4 if(!exists $args->{init_arg}){
519 $args->{init_arg} = $name;
520 }
521  
522 4 # 'required' requires either 'init_arg', 'builder', or 'default'
523 my $can_be_required = defined( $args->{init_arg} );
524 4 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if (exists $args->{'builder'}) { } 0 4 4
elsif (exists $args->{'default'}) { } 0 4 4
525 if(exists $args->{builder}){
526 # XXX:
527 # Moose refuses a CODE ref builder, but Mouse doesn't for backward compatibility
528 # This feature will be changed in a future. (gfx)
529 $class->throw_error('builder must be a defined scalar value which is a method name')
530 0 ▶ #if ref $args->{builder} || !defined $args->{builder};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args->{"builder"} 0 0 0
531 if !defined $args->{builder};
532 0  
533 $can_be_required++;
534 }
535 0 ▶ elsif(exists $args->{default}){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args->{"default"} and ref $args->{"default"} ne "CODE") 0 0 0
Condition0%0/3
ref $args->{"default"} and ref $args->{"default"} ne "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $args->{"default"} and ref $args->{"default"} ne "CODE"
ref $args->{"default"} ref $args->{"default"} ne "CODE"
Truth table0%0/3
A and B
A= ref $args->{"default"}B= ref $args->{"default"} ne "CODE"
ABresult
0X0
100
111
536 0 if(ref $args->{default} && ref($args->{default}) ne 'CODE'){
537 $class->throw_error("References are not allowed as default values, you must "
538 . "wrap the default of '$name' in a CODE reference (ex: sub { [] } and not [])");
539 0 }
540 $can_be_required++;
541 }
542 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"required"} and not $can_be_required) 0 4 4
Condition33%1/3
$args->{"required"} and not $can_be_required
!ll&&!rl&&r
400
MC/DC0%0/2
$args->{"required"} and not $can_be_required
$args->{"required"} not $can_be_required
Truth table33%1/3
A and not(B)
A= $args->{"required"}B= not $can_be_required
ABresult
0X0
100
111
543 0 if( $args->{required} && !$can_be_required ) {
544 $class->throw_error("You cannot have a required attribute ($name) without a default, builder, or an init_arg");
545 }
546  
547 # taken from Mouse::Meta::Attribute->new and ->_process_args
548 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"is"}) 4 0 4
549 4 if(exists $args->{is}){
550 my $is = $args->{is};
551 4 ▶ 
Branch: 3 branches
BranchTrueFalseTotal
if ($is eq 'ro') { } 0 4 4
elsif ($is eq 'rw') { } 4 0 4
elsif ($is eq 'bare') { } 0 0 0
552 0 ▶ if($is eq 'ro'){
Condition0%0/3
$args->{"reader"} ||= $name
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{"reader"} ||= $name
$args->{"reader"} $name
Truth table0%0/3
A ||= B
A= $args->{"reader"}B= $name
ABresult
1X1
011
000
553 $args->{reader} ||= $name;
554 }
555 4 ▶ elsif($is eq 'rw'){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{'writer'}) { } 0 4 4
556 0 ▶ if(exists $args->{writer}){
Condition0%0/3
$args->{"reader"} ||= $name
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{"reader"} ||= $name
$args->{"reader"} $name
Truth table0%0/3
A ||= B
A= $args->{"reader"}B= $name
ABresult
1X1
011
000
557 $args->{reader} ||= $name;
558 }
559 4 ▶ else{
Condition33%1/3
$args->{"accessor"} ||= $name
l!l&&r!l&&!r
040
MC/DC0%0/2
$args->{"accessor"} ||= $name
$args->{"accessor"} $name
Truth table33%1/3
A ||= B
A= $args->{"accessor"}B= $name
ABresult
1X1
011
000
560 $args->{accessor} ||= $name;
561 }
562 }
563 elsif($is eq 'bare'){
564 # do nothing, but don't complain (later) about missing methods
565 }
566 0 ▶ else{
Branch: 1 branch
BranchTrueFalseTotal
unless defined $is 0 0 0
567 0 $is = 'undef' if !defined $is;
568 $class->throw_error("I do not understand this option (is => $is) on attribute ($name)");
569 }
570 }
571 4  
572 4 ▶ my $tc;
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"isa"}) 0 4 4
573 0 if(exists $args->{isa}){
574 $tc = $args->{type_constraint} = Mouse::Util::TypeConstraints::find_or_create_isa_type_constraint($args->{isa});
575 }
576 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"does"}) 0 4 4
577 0 ▶ if(exists $args->{does}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tc) { } 0 0 0
578 0 if(defined $tc){ # both isa and does supplied
579 0 my $does_ok = do{
580 0 local $@;
581 eval{ "$tc"->does($args->{does}) };
582 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
unless ($does_ok) 0 0 0
583 0 if(!$does_ok){
584 $class->throw_error("Cannot have both an isa option and a does option because '$tc' does not do '$args->{does}' on attribute ($name)");
585 }
586 }
587 0 else {
588 $tc = $args->{type_constraint} = Mouse::Util::TypeConstraints::find_or_create_does_type_constraint($args->{does});
589 }
590 }
591 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"coerce"}) 0 4 4
592 0 ▶ if($args->{coerce}){
Branch: 1 branch
BranchTrueFalseTotal
defined $tc or $class->throw_error("You cannot have coercion without specifying a type constraint on attribute ($name)") 0 0 0
593 defined($tc)
594 || $class->throw_error("You cannot have coercion without specifying a type constraint on attribute ($name)");
595  
596 0 ▶ $args->{weak_ref}
Branch: 1 branch
BranchTrueFalseTotal
$args->{"weak_ref"} and $class->throw_error("You cannot have a weak reference to a coerced value on attribute ($name)") 0 0 0
597 && $class->throw_error("You cannot have a weak reference to a coerced value on attribute ($name)");
598 }
599 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"lazy_build"}) 0 4 4
600 if ($args->{lazy_build}) {
601 0 ▶ exists($args->{default})
Branch: 1 branch
BranchTrueFalseTotal
exists $args->{"default"} and $class->throw_error("You can not use lazy_build and default for the same attribute ($name)") 0 0 0
602 && $class->throw_error("You can not use lazy_build and default for the same attribute ($name)");
603 0  
604 0 ▶ $args->{lazy} = 1;
Condition0%0/2
$args->{"builder"} ||= "_build_$name"
l!l
00
MC/DC0%0/1
$args->{"builder"} ||= "_build_$name"
$args->{"builder"}
Truth table0%0/2
A
A= $args->{"builder"}
Aresult
11
00
605 0 ▶ $args->{builder} ||= "_build_${name}";
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^_/) { } 0 0 0
606 0 ▶ if ($name =~ /^_/) {
Condition0%0/2
$args->{"clearer"} ||= "_clear$name"
l!l
00
MC/DC0%0/1
$args->{"clearer"} ||= "_clear$name"
$args->{"clearer"}
Truth table0%0/2
A
A= $args->{"clearer"}
Aresult
11
00
607 0 ▶ $args->{clearer} ||= "_clear${name}";
Condition0%0/2
$args->{"predicate"} ||= "_has$name"
l!l
00
MC/DC0%0/1
$args->{"predicate"} ||= "_has$name"
$args->{"predicate"}
Truth table0%0/2
A
A= $args->{"predicate"}
Aresult
11
00
608 $args->{predicate} ||= "_has${name}";
609 }
610 0 ▶ else {
Condition0%0/2
$args->{"clearer"} ||= "clear_$name"
l!l
00
MC/DC0%0/1
$args->{"clearer"} ||= "clear_$name"
$args->{"clearer"}
Truth table0%0/2
A
A= $args->{"clearer"}
Aresult
11
00
611 0 ▶ $args->{clearer} ||= "clear_${name}";
Condition0%0/2
$args->{"predicate"} ||= "has_$name"
l!l
00
MC/DC0%0/1
$args->{"predicate"} ||= "has_$name"
$args->{"predicate"}
Truth table0%0/2
A
A= $args->{"predicate"}
Aresult
11
00
612 $args->{predicate} ||= "has_${name}";
613 }
614 }
615 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"auto_deref"}) 0 4 4
616 0 ▶ if ($args->{auto_deref}) {
Branch: 1 branch
BranchTrueFalseTotal
defined $tc or $class->throw_error("You cannot auto-dereference without specifying a type constraint on attribute ($name)") 0 0 0
617 defined($tc)
618 || $class->throw_error("You cannot auto-dereference without specifying a type constraint on attribute ($name)");
619 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
$tc->is_a_type_of("ArrayRef") or $tc->is_a_type_of("HashRef") or $class->throw_error("You cannot auto-dereference anything other than a ArrayRef or HashRef on attribute ($name)") 0 0 0
Condition0%0/3
$tc->is_a_type_of("ArrayRef") or $tc->is_a_type_of("HashRef")
l!l&&r!l&&!r
000
MC/DC0%0/2
$tc->is_a_type_of("ArrayRef") or $tc->is_a_type_of("HashRef")
$tc->is_a_type_of("ArrayRef") $tc->is_a_type_of("HashRef")
Truth table0%0/3
A or B
A= $tc->is_a_type_of("ArrayRef")B= $tc->is_a_type_of("HashRef")
ABresult
1X1
011
000
620 ( $tc->is_a_type_of('ArrayRef') || $tc->is_a_type_of('HashRef') )
621 || $class->throw_error("You cannot auto-dereference anything other than a ArrayRef or HashRef on attribute ($name)");
622 }
623 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"trigger"}) 0 4 4
624 if (exists $args->{trigger}) {
625 0 ▶ ('CODE' eq ref $args->{trigger})
Branch: 1 branch
BranchTrueFalseTotal
"CODE" eq ref $args->{"trigger"} or $class->throw_error("Trigger must be a CODE ref on attribute ($name)") 0 0 0
626 || $class->throw_error("Trigger must be a CODE ref on attribute ($name)");
627 }
628 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"lazy"}) 0 4 4
629 if ($args->{lazy}) {
630 0 ▶ (exists $args->{default} || defined $args->{builder})
Branch: 1 branch
BranchTrueFalseTotal
exists $args->{"default"} or defined $args->{"builder"} or $class->throw_error("You cannot have a lazy attribute ($name) without specifying a default value for it") 0 0 0
Condition0%0/3
exists $args->{"default"} or defined $args->{"builder"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $args->{"default"} or defined $args->{"builder"}
exists $args->{"default"} defined $args->{"builder"}
Truth table0%0/3
A or B
A= exists $args->{"default"}B= defined $args->{"builder"}
ABresult
1X1
011
000
631 || $class->throw_error("You cannot have a lazy attribute ($name) without specifying a default value for it");
632 }
633 4  
634 return;
635 }
636  
637  
638 package Mouse::Meta::TypeConstraint;
639  
640 2 ▶use overload
Subroutine BEGIN: called CC=1 SCAR=0.0
641 '""' => '_as_string',
642 '0+' => '_identity',
643 '|' => '_unite',
644 2  
645 fallback => 1;
646 0 ▶ 
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
647 0 ▶sub name { $_[0]->{name} }
Subroutine parent: not called CC=1 SCAR=6.9
Pod documented
648 0 ▶sub parent { $_[0]->{parent} }
Subroutine message: not called CC=1 SCAR=6.9
Pod documented
649 sub message { $_[0]->{message} }
650 0 ▶ 
Subroutine _identity: not called CC=1 SCAR=6.9
651 sub _identity { Scalar::Util::refaddr($_[0]) } # overload 0+
652 0 ▶ 
Subroutine type_parameter: not called CC=1 SCAR=6.9
Pod undocumented
653 0 ▶sub type_parameter { $_[0]->{type_parameter} }
Subroutine _compiled_type_constraint: not called CC=1 SCAR=6.9
654 sub _compiled_type_constraint{ $_[0]->{compiled_type_constraint} }
655 0 ▶ 
Subroutine __is_parameterized: not called CC=1 SCAR=6.9
656 0 ▶sub __is_parameterized { exists $_[0]->{type_parameter} }
Subroutine has_coercion: not called CC=1 SCAR=6.9
Pod documented
657 sub has_coercion { exists $_[0]->{_compiled_type_coercion} }
658  
659 6 ▶ 
Subroutine compile_type_constraint: called CC=7 SCAR=29.2
Pod undocumented
660 6 sub compile_type_constraint{
661 my($self) = @_;
662  
663 6 # add parents first
664 6 ▶ my @checks;
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parent) 6 6 12
665 6 ▶ for(my $parent = $self->{parent}; defined $parent; $parent = $parent->{parent}){
Branch: 2 branches
BranchTrueFalseTotal
if ($parent->{'hand_optimized_type_constraint'}) { } 0 6 6
elsif ($parent->{'constraint'}) { } 0 6 6
666 0 if($parent->{hand_optimized_type_constraint}){
667 0 unshift @checks, $parent->{hand_optimized_type_constraint};
668 last; # a hand optimized constraint must include all the parents
669 }
670 0 elsif($parent->{constraint}){
671 unshift @checks, $parent->{constraint};
672 }
673 }
674  
675 6 ▶ # then add child
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"constraint"}) 0 6 6
676 0 if($self->{constraint}){
677 push @checks, $self->{constraint};
678 }
679 6 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type_constraints"}) 0 6 6
680 0 if($self->{type_constraints}){ # Union
681 0 ▶ my @types = map{ $_->{compiled_type_constraint} } @{ $self->{type_constraints} };
Subroutine __ANON__: not called CC=3 SCAR=24.8
682 0 push @checks, sub{
683 0 ▶ foreach my $c(@types){
Branch: 1 branch
BranchTrueFalseTotal
if &$c($_[0]) 0 0 0
684 return 1 if $c->($_[0]);
685 0 }
686 0 return 0;
687 };
688 }
689 6 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (@checks == 0) { } 6 0 6
690 6 if(@checks == 0){
691 $self->{compiled_type_constraint} = \&Mouse::Util::TypeConstraints::Any;
692 }
693 0 ▶ else{
Subroutine __ANON__: not called CC=4 SCAR=30.0
694 0 $self->{compiled_type_constraint} = sub{
695 0 my(@args) = @_;
696 0 for ($args[0]) { # local $_ will cancel tie-ness due to perl's bug
697 0 ▶ foreach my $c(@checks){
Branch: 1 branch
BranchTrueFalseTotal
unless &$c(@args) 0 0 0
698 return undef if !$c->(@args);
699 }
700 0 }
701 0 return 1;
702 };
703 6 }
704 return;
705 }
706 0 ▶ 
Subroutine check: not called CC=1 SCAR=6.9
Pod documented
707 0 sub check {
708 0 my $self = shift;
709 return $self->_compiled_type_constraint->(@_);
710 }
711  
712  
713 package Mouse::Object;
714 8 ▶ 
Subroutine BUILDARGS: called CC=3 SCAR=16.0
Pod documented
715 8 sub BUILDARGS {
716 my $class = shift;
717 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ == 1) { } 0 8 8
718 0 ▶ if (scalar @_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq "HASH" or $class->meta->throw_error("Single parameters to new() must be a HASH ref") 0 0 0
719 (ref($_[0]) eq 'HASH')
720 || $class->meta->throw_error("Single parameters to new() must be a HASH ref");
721 0  
722 return {%{$_[0]}};
723 }
724 8 else {
725 return {@_};
726 }
727 }
728 4 ▶ 
Subroutine new: called CC=1 SCAR=0.0
Pod documented
729 4 sub new {
730 4 my $class = shift;
731 4 my $args = $class->BUILDARGS(@_);
732 return $class->meta->new_object($args);
733 }
734 4 ▶ 
Subroutine DESTROY: called CC=5 SCAR=26.5
735 4 sub DESTROY {
736 my $self = shift;
737 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can("DEMOLISH") 4 0 4
738 return unless $self->can('DEMOLISH'); # short circuit
739 0  
740 0 my $e = do{
741 0 local $?;
742 0 local $@;
743 eval{
744 # DEMOLISHALL
745  
746 # We cannot count on being able to retrieve a previously made
747 # metaclass, _or_ being able to make a new one during global
748 # destruction. However, we should still be able to use mro at
749 # that time (at least tests suggest so ;)
750 0  
751 0 ▶ foreach my $class (@{ Mouse::Util::get_linear_isa(ref $self) }) {
Condition0%0/2
Mouse::Util::get_code_ref($class, 'DEMOLISH') || (next)
l!l
00
MC/DC0%0/1
Mouse::Util::get_code_ref($class, 'DEMOLISH') || (next)
Mouse::Util::get_code_ref($class, 'DEMOLISH')
Truth table0%0/2
A
A= Mouse::Util::get_code_ref($class, 'DEMOLISH')
Aresult
11
00
752 my $demolish = Mouse::Util::get_code_ref($class, 'DEMOLISH')
753 || next;
754 0  
755 $self->$demolish(Mouse::Util::in_global_destruction());
756 }
757 0 };
758 $@;
759 };
760 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
761 0 ▶ no warnings 'misc';
Branch: 1 branch
BranchTrueFalseTotal
if $e 0 0 0
762 die $e if $e; # rethrow
763 }
764 0 ▶ 
Subroutine BUILDALL: not called CC=4 SCAR=30.0
Pod documented
765 0 sub BUILDALL {
766 my $self = shift;
767  
768 0 ▶ # short circuit
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can("BUILD") 0 0 0
769 return unless $self->can('BUILD');
770 0  
771 0 ▶ for my $class (reverse $self->meta->linearized_isa) {
Condition0%0/2
Mouse::Util::get_code_ref($class, 'BUILD') || (next)
l!l
00
MC/DC0%0/1
Mouse::Util::get_code_ref($class, 'BUILD') || (next)
Mouse::Util::get_code_ref($class, 'BUILD')
Truth table0%0/2
A
A= Mouse::Util::get_code_ref($class, 'BUILD')
Aresult
11
00
772 my $build = Mouse::Util::get_code_ref($class, 'BUILD')
773 || next;
774 0  
775 $self->$build(@_);
776 0 }
777 return;
778 }
779  
780 2 sub DEMOLISHALL;
781 *DEMOLISHALL = \&DESTROY;
782  
783 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
784 BEGIN{ # lib/Mouse/Exporter.pm
785 2 ▶package Mouse::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
786 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
787 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
788 use Carp ();
789 2  
790 my %SPEC;
791  
792 # it must be "require", because Mouse::Util depends on Mouse::Exporter,
793 2 # which depends on Mouse::Util::import()
794 require Mouse::Util;
795 8 ▶ 
Subroutine import: called CC=1 SCAR=0.0
796 8 sub import{
797 8 strict->import;
798 8 warnings->import('all', FATAL => 'recursion');
799 return;
800 }
801  
802 10 ▶ 
Subroutine setup_import_methods: called CC=2 SCAR=9.2
Pod documented
803 10 sub setup_import_methods{
804 my($class, %args) = @_;
805 10 ▶ 
Condition33%1/3
$args{"exporting_package"} ||= caller()
l!l&&r!l&&!r
0100
MC/DC0%0/2
$args{"exporting_package"} ||= caller()
$args{"exporting_package"} caller()
Truth table33%1/3
A ||= B
A= $args{"exporting_package"}B= caller()
ABresult
1X1
011
000
806 my $exporting_package = $args{exporting_package} ||= caller();
807 10  
808 my($import, $unimport) = $class->build_import_methods(%args);
809  
810 Mouse::Util::install_subroutines($exporting_package,
811 import => $import,
812 unimport => $unimport,
813 0 ▶ 
Subroutine __ANON__: not called CC=1 SCAR=6.9
814 0 export_to_level => sub {
815 0 my($package, $level, undef, @args) = @_; # the third argument is redundant
816 $package->import({ into_level => $level + 1 }, @args);
817 0 ▶ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
818 0 export => sub {
819 0 my($package, $into, @args) = @_;
820 $package->import({ into => $into }, @args);
821 10 },
822 10 );
823 return;
824 }
825 10 ▶ 
Subroutine build_import_methods: called CC=20 SCAR=30.5
Pod documented
826 10 sub build_import_methods{
827 my($self, %args) = @_;
828 10 ▶ 
Condition33%1/3
$args{"exporting_package"} ||= caller()
l!l&&r!l&&!r
1000
MC/DC0%0/2
$args{"exporting_package"} ||= caller()
$args{"exporting_package"} caller()
Truth table33%1/3
A ||= B
A= $args{"exporting_package"}B= caller()
ABresult
1X1
011
000
829 my $exporting_package = $args{exporting_package} ||= caller();
830 10  
831 $SPEC{$exporting_package} = \%args;
832  
833 10 # canonicalize args
834 10 ▶ my @export_from;
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'also'}) { } 2 8 10
835 2 if($args{also}){
836 2 my %seen;
837 my @stack = ($exporting_package);
838 2 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (my $current = shift @stack) 4 2 6
839 4 while(my $current = shift @stack){
840 push @export_from, $current;
841 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $also = $SPEC{$current}{"also"} or next 2 2 4
842 0 ▶ my $also = $SPEC{$current}{also} or next;
Branch: 1 branch
BranchTrueFalseTotal
ref $also ? : 0 2 2
843 push @stack, grep{ !$seen{$_}++ } ref($also) ? @{ $also } : $also;
844 }
845 }
846 8 else{
847 @export_from = ($exporting_package);
848 }
849 10  
850 my %exports;
851 10 my @removables;
852 my @all;
853 10  
854 my @init_meta_methods;
855 10  
856 12 ▶ foreach my $package(@export_from){
Branch: 1 branch
BranchTrueFalseTotal
my $spec = $SPEC{$package} or next 12 0 12
857 my $spec = $SPEC{$package} or next;
858 12 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (my $as_is = $spec->{"as_is"}) 10 2 12
859 10 if(my $as_is = $spec->{as_is}){
860 140 foreach my $thingy (@{$as_is}){
861 my($code_package, $code_name, $code);
862 140 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (ref $thingy) { } 12 128 140
863 12 if(ref($thingy)){
864 12 $code = $thingy;
865 ($code_package, $code_name) = Mouse::Util::get_code_info($code);
866 }
867 128 else{
868 128 $code_package = $package;
869 2 ▶ $code_name = $thingy;
Subroutine BEGIN: called CC=1 SCAR=0.0
870 128 no strict 'refs';
871 $code = \&{ $code_package . '::' . $code_name };
872 }
873 140  
874 140 push @all, $code_name;
875 140 ▶ $exports{$code_name} = $code;
Branch: 1 branch
BranchTrueFalseTotal
if ($code_package eq $package) 128 12 140
876 128 if($code_package eq $package){
877 push @removables, $code_name;
878 }
879 }
880 }
881 12 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (my $init_meta = $package->can("init_meta")) 6 6 12
882 0 ▶ if(my $init_meta = $package->can('init_meta')){
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ == $init_meta;} @init_meta_methods) 6 0 6
883 6 if(!grep{ $_ == $init_meta } @init_meta_methods){
884 push @init_meta_methods, $init_meta;
885 }
886 }
887 10 }
888 10 $args{EXPORTS} = \%exports;
889 $args{REMOVABLES} = \@removables;
890 10 ▶ 
Condition50%1/2
$args{"groups"}{"all"} ||= \@all
l!l
010
MC/DC0%0/1
$args{"groups"}{"all"} ||= \@all
$args{"groups"}{"all"}
Truth table50%1/2
A
A= $args{"groups"}{"all"}
Aresult
11
00
891 $args{groups}{all} ||= \@all;
892 10 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (my $default_list = $args{'groups'}{'default'}) { } 2 8 10
893 2 if(my $default_list = $args{groups}{default}){
894 2 my %default;
895 0 ▶ foreach my $keyword(@{$default_list}){
Condition0%0/2
$exports{$keyword} || Carp::confess(qq[The $exporting_package package does not export "$keyword"])
l!l
00
MC/DC0%0/1
$exports{$keyword} || Carp::confess(qq[The $exporting_package package does not export "$keyword"])
$exports{$keyword}
Truth table0%0/2
A
A= $exports{$keyword}
Aresult
11
00
896 $default{$keyword} = $exports{$keyword}
897 || Carp::confess(qq{The $exporting_package package does not export "$keyword"});
898 2 }
899 $args{DEFAULT} = \%default;
900 }
901 8 ▶ else{
Condition50%1/2
$args{"groups"}{"default"} ||= \@all
l!l
08
MC/DC0%0/1
$args{"groups"}{"default"} ||= \@all
$args{"groups"}{"default"}
Truth table50%1/2
A
A= $args{"groups"}{"default"}
Aresult
11
00
902 8 $args{groups}{default} ||= \@all;
903 $args{DEFAULT} = $args{EXPORTS};
904 }
905 10 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (@init_meta_methods) 6 4 10
906 6 if(@init_meta_methods){
907 $args{INIT_META} = \@init_meta_methods;
908 }
909 10  
910 return (\&do_import, \&do_unimport);
911 }
912  
913 36 ▶# the entity of general import()
Subroutine do_import: called CC=18 SCAR=35.5
Pod undocumented
914 36 sub do_import {
915 my($package, @args) = @_;
916 36 ▶ 
Condition50%1/2
$SPEC{$package} || Carp::confess("The package $package package does not use Mouse::Exporter")
l!l
360
MC/DC0%0/1
$SPEC{$package} || Carp::confess("The package $package package does not use Mouse::Exporter")
$SPEC{$package}
Truth table50%1/2
A
A= $SPEC{$package}
Aresult
11
00
917 my $spec = $SPEC{$package}
918 || Carp::confess("The package $package package does not use Mouse::Exporter");
919 36 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
ref $args[0] ? : 0 36 36
920 my $into = _get_caller_package(ref($args[0]) ? shift @args : undef);
921 36  
922 my @exports;
923 my @traits;
924 36 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 28 36 64
925 28 while(@args){
926 28 ▶ my $arg = shift @args;
Branch: 2 branches
BranchTrueFalseTotal
if ($arg =~ s/^-//) { } 0 28 28
elsif ($arg =~ s/^://) { } 22 6 28
927 0 ▶ if($arg =~ s/^-//){
Branch: 1 branch
BranchTrueFalseTotal
if ($arg eq 'traits') { } 0 0 0
928 0 ▶ if($arg eq 'traits'){
Branch: 1 branch
BranchTrueFalseTotal
ref $args[0] ? : 0 0 0
929 push @traits, ref($args[0]) ? @{shift(@args)} : shift(@args);
930 }
931 0 else {
932 Mouse::Util::not_supported("-$arg");
933 }
934 }
935 22 ▶ elsif($arg =~ s/^://){
Condition50%1/2
$spec->{'groups'}{$arg} || Carp::confess(qq[The $package package does not export the group "$arg"])
l!l
220
MC/DC0%0/1
$spec->{'groups'}{$arg} || Carp::confess(qq[The $package package does not export the group "$arg"])
$spec->{'groups'}{$arg}
Truth table50%1/2
A
A= $spec->{'groups'}{$arg}
Aresult
11
00
936 my $group = $spec->{groups}{$arg}
937 22 || Carp::confess(qq{The $package package does not export the group "$arg"});
938 push @exports, @{$group};
939 }
940 6 else{
941 push @exports, $arg;
942 }
943 }
944 36  
945 36 strict->import;
946 warnings->import('all', FATAL => 'recursion');
947 36 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if ($spec->{'INIT_META'}) { } 4 32 36
elsif (@traits) { } 0 32 32
948 4 if($spec->{INIT_META}){
949 4 my $meta;
950 4 foreach my $init_meta(@{$spec->{INIT_META}}){
951 $meta = $package->$init_meta(for_class => $into);
952 }
953 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (@traits) 0 4 4
954 0 if(@traits){
955 my $type = (split /::/, ref $meta)[-1]; # e.g. "Class" for "My::Meta::Class"
956 0 ▶ @traits = map{
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 0 0
957 ref($_)
958 ? $_
959 : Mouse::Util::resolve_metaclass_alias($type => $_, trait => 1)
960 } @traits;
961 0  
962 0 ▶ require Mouse::Util::MetaRole;
Branch: 1 branch
BranchTrueFalseTotal
Mouse::Util::is_a_metarole($into->meta) ? : 0 0 0
963 Mouse::Util::MetaRole::apply_metaroles(
964 for => $into,
965 Mouse::Util::is_a_metarole($into->meta)
966 ? (role_metaroles => { role => \@traits })
967 : (class_metaroles => { class => \@traits }),
968 );
969 }
970 }
971 0 elsif(@traits){
972 Carp::confess("Cannot provide traits when $package does not have an init_meta() method");
973 }
974 36 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (@exports) { } 24 12 36
975 24 if(@exports){
976 24 my @export_table;
977 foreach my $keyword(@exports){
978 94 ▶ push @export_table,
Condition50%1/2
$spec->{'EXPORTS'}{$keyword} || Carp::confess(qq[The $package package does not export "$keyword"])
l!l
940
MC/DC0%0/1
$spec->{'EXPORTS'}{$keyword} || Carp::confess(qq[The $package package does not export "$keyword"])
$spec->{'EXPORTS'}{$keyword}
Truth table50%1/2
A
A= $spec->{'EXPORTS'}{$keyword}
Aresult
11
00
979 $keyword => ($spec->{EXPORTS}{$keyword}
980 || Carp::confess(qq{The $package package does not export "$keyword"})
981 );
982 24 }
983 Mouse::Util::install_subroutines($into, @export_table);
984 }
985 12 else{
986 Mouse::Util::install_subroutines($into, %{$spec->{DEFAULT}});
987 36 }
988 return;
989 }
990  
991 0 ▶# the entity of general unimport()
Subroutine do_unimport: not called CC=6 SCAR=34.3
Pod undocumented
992 0 sub do_unimport {
993 my($package, $arg) = @_;
994 0 ▶ 
Condition0%0/2
$SPEC{$package} || Carp::confess("The package $package does not use Mouse::Exporter")
l!l
00
MC/DC0%0/1
$SPEC{$package} || Carp::confess("The package $package does not use Mouse::Exporter")
$SPEC{$package}
Truth table0%0/2
A
A= $SPEC{$package}
Aresult
11
00
995 my $spec = $SPEC{$package}
996 || Carp::confess("The package $package does not use Mouse::Exporter");
997 0  
998 my $from = _get_caller_package($arg);
999 0  
1000 2 ▶ my $stash = do{
Subroutine BEGIN: called CC=1 SCAR=0.0
1001 0 no strict 'refs';
1002 \%{$from . '::'}
1003 };
1004 0  
1005 0 ▶ for my $keyword (@{ $spec->{REMOVABLES} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless exists $stash->{$keyword} 0 0 0
1006 0 next if !exists $stash->{$keyword};
1007 my $gv = \$stash->{$keyword};
1008  
1009 0 ▶ # remove what is from us
Branch: 1 branch
BranchTrueFalseTotal
if (ref $gv eq "GLOB" and *{$gv;}{"CODE"} == $spec->{"EXPORTS"}{$keyword}) 0 0 0
Condition0%0/3
ref $gv eq "GLOB" and *{$gv;}{"CODE"} == $spec->{"EXPORTS"}{$keyword}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $gv eq "GLOB" and *{$gv;}{"CODE"} == $spec->{"EXPORTS"}{$keyword}
ref $gv eq "GLOB" *{$gv;}{"CODE"} == $spec->{"EXPORTS"}{$keyword}
Truth table0%0/3
A and B
A= ref $gv eq "GLOB"B= *{$gv;}{"CODE"} == $spec->{"EXPORTS"}{$keyword}
ABresult
0X0
100
111
1010 0 if(ref($gv) eq 'GLOB' && *{$gv}{CODE} == $spec->{EXPORTS}{$keyword}){
1011 delete $stash->{$keyword};
1012 }
1013 0 }
1014 return;
1015 }
1016 36 ▶ 
Subroutine _get_caller_package: called CC=4 SCAR=20.1
1017 36 sub _get_caller_package {
1018 my($arg) = @_;
1019  
1020 # We need one extra level because it's called by import so there's a layer
1021 36 ▶ # of indirection
Branch: 1 branch
BranchTrueFalseTotal
if (ref $arg) { } 0 36 36
1022 if(ref $arg){
1023 return defined($arg->{into}) ? $arg->{into}
1024 0 ▶ : defined($arg->{into_level}) ? scalar caller(1 + $arg->{into_level})
Branch: 2 branches
BranchTrueFalseTotal
defined $arg->{'into'} ? : 0 0 0
defined $arg->{'into_level'} ? : 0 0 0
1025 : scalar caller(1);
1026 }
1027 36 else{
1028 return scalar caller(1);
1029 }
1030 }
1031  
1032 2 ▶}
Subroutine BEGIN: called CC=2 SCAR=9.1
1033 BEGIN{ # lib/Mouse/Util.pm
1034 2 ▶package Mouse::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
1035 use Mouse::Exporter; # enables strict and warnings
1036  
1037 # Note that those which don't exist here are defined in XS or Mouse::PurePerl
1038  
1039 # must be here because it will be referred by other modules loaded
1040 sub get_linear_isa($;$); ## no critic
1041  
1042 60 ▶# must be here because it will called in Mouse::Exporter
Subroutine install_subroutines: called CC=2 SCAR=6.9
Pod undocumented
1043 60 sub install_subroutines {
1044 my $into = shift;
1045 60 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@_, 0, 2)) 196 60 256
1046 2 ▶ while(my($name, $code) = splice @_, 0, 2){
Subroutine BEGIN: called CC=1 SCAR=0.0
1047 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1048 2 ▶ no warnings 'once', 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
1049 196 use warnings FATAL => 'uninitialized';
1050 *{$into . '::' . $name} = \&{$code};
1051 60 }
1052 return;
1053 }
1054 2 ▶ 
Subroutine BEGIN: called CC=8 SCAR=26.5
1055 BEGIN{
1056 2 # This is used in Mouse::PurePerl
1057 Mouse::Exporter->setup_import_methods(
1058 as_is => [qw(
1059 find_meta
1060 does_role
1061 resolve_metaclass_alias
1062 apply_all_roles
1063 english_list
1064  
1065 load_class
1066 is_class_loaded
1067  
1068 get_linear_isa
1069 get_code_info
1070  
1071 get_code_package
1072 get_code_ref
1073  
1074 not_supported
1075  
1076 does meta throw_error dump
1077 )],
1078 groups => {
1079 default => [], # export no functions by default
1080  
1081 # The ':meta' group is 'use metaclass' for Mouse
1082 meta => [qw(does meta dump throw_error)],
1083 },
1084 );
1085 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
1086 use version; our $VERSION = version->declare('v2.6.2');
1087 2 ▶ 
Condition33%2/6
defined &Mouse::Util::is_valid_class_name || $ENV{'MOUSE_PUREPERL'} || $ENV{'PERL_ONLY'}
l!l&&r!l&&!r
200
defined &Mouse::Util::is_valid_class_name or $ENV{"MOUSE_PUREPERL"}
l!l&&r!l&&!r
200
MC/DC0%0/3
defined &Mouse::Util::is_valid_class_name || $ENV{'MOUSE_PUREPERL'} || $ENV{'PERL_ONLY'}
defined &Mouse::Util::is_valid_class_name $ENV{"MOUSE_PUREPERL"} $ENV{'PERL_ONLY'}
Truth table25%1/4
A or B || C
A= defined &Mouse::Util::is_valid_class_nameB= $ENV{"MOUSE_PUREPERL"}C= $ENV{'PERL_ONLY'}
ABCresult
1XX1
01X1
0011
0000
1088 my $xs = !(defined(&is_valid_class_name) || $ENV{MOUSE_PUREPERL} || $ENV{PERL_ONLY});
1089  
1090 # Because Mouse::Util is loaded first in all the Mouse sub-modules,
1091 2 ▶ # XSLoader must be placed here, not in Mouse.pm.
Branch: 1 branch
BranchTrueFalseTotal
if ($xs) 0 4 4
1092 if($xs){
1093 # XXX: XSLoader tries to get the object path from caller's file name
1094 0 # $hack_mouse_file fools its mechanism
1095 0 ▶ (my $hack_mouse_file = __FILE__) =~ s/.Util//; # .../Mouse/Util.pm -> .../Mouse.pm
Condition0%0/2
eval sprintf("#line %d %s\n", __LINE__, $hack_mouse_file) . "\n\t\t\tlocal \$^W = 0; # workaround 'redefine' warning to &install_subroutines\n\t\t\tno warnings 'redefine';\n\t\t\trequire XSLoader;\n\t\t\tXSLoader::load('Mouse', \$VERSION);\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Constructor::XS' }, ':meta');\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Destructor::XS' }, ':meta');\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Accessor::XS' }, ':meta');\n\t\t\treturn 1;\n\t\t" || 0
l!l
00
MC/DC0%0/1
eval sprintf("#line %d %s\n", __LINE__, $hack_mouse_file) . "\n\t\t\tlocal \$^W = 0; # workaround 'redefine' warning to &install_subroutines\n\t\t\tno warnings 'redefine';\n\t\t\trequire XSLoader;\n\t\t\tXSLoader::load('Mouse', \$VERSION);\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Constructor::XS' }, ':meta');\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Destructor::XS' }, ':meta');\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Accessor::XS' }, ':meta');\n\t\t\treturn 1;\n\t\t" || 0
eval sprintf("#line %d %s\n", __LINE__, $hack_mouse_file) . "\n\t\t\tlocal \$^W = 0; # workaround 'redefine' warning to &install_subroutines\n\t\t\tno warnings 'redefine';\n\t\t\trequire XSLoader;\n\t\t\tXSLoader::load('Mouse', \$VERSION);\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Constructor::XS' }, ':meta');\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Destructor::XS' }, ':meta');\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Accessor::XS' }, ':meta');\n\t\t\treturn 1;\n\t\t"
Truth table0%0/2
A
A= eval sprintf("#line %d %s\n", __LINE__, $hack_mouse_file) . "\n\t\t\tlocal \$^W = 0; # workaround 'redefine' warning to &install_subroutines\n\t\t\tno warnings 'redefine';\n\t\t\trequire XSLoader;\n\t\t\tXSLoader::load('Mouse', \$VERSION);\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Constructor::XS' }, ':meta');\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Destructor::XS' }, ':meta');\n\t\t\tMouse::Util->import({ into => 'Mouse::Meta::Method::Accessor::XS' }, ':meta');\n\t\t\treturn 1;\n\t\t"
Aresult
11
00
1096 $xs = eval sprintf("#line %d %s\n", __LINE__, $hack_mouse_file) . q{
1097 local $^W = 0; # workaround 'redefine' warning to &install_subroutines
1098 no warnings 'redefine';
1099 require XSLoader;
1100 XSLoader::load('Mouse', $VERSION);
1101 Mouse::Util->import({ into => 'Mouse::Meta::Method::Constructor::XS' }, ':meta');
1102 Mouse::Util->import({ into => 'Mouse::Meta::Method::Destructor::XS' }, ':meta');
1103 Mouse::Util->import({ into => 'Mouse::Meta::Method::Accessor::XS' }, ':meta');
1104 return 1;
1105 0 ▶ } || 0;
Branch: 1 branch
BranchTrueFalseTotal
if $@ and $ENV{"MOUSE_XS"} 0 0 0
Condition0%0/3
$@ and $ENV{"MOUSE_XS"}
!ll&&!rl&&r
000
MC/DC0%0/2
$@ and $ENV{"MOUSE_XS"}
$@ $ENV{"MOUSE_XS"}
Truth table0%0/3
A and B
A= $@B= $ENV{"MOUSE_XS"}
ABresult
0X0
100
111
1106 warn $@ if $@ && $ENV{MOUSE_XS};
1107 }
1108 2 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless ($xs) 2 0 2
1109 2 if(!$xs){
1110 require 'Mouse/PurePerl.pm'; # we don't want to create its namespace
1111 }
1112  
1113 2 {
1114 0 ▶ my $value = $xs; # avoid "Constants from lexical variables potentially modified elsewhere are deprecated"
Subroutine __ANON__: not called CC=1 SCAR=1.2
1115 *MOUSE_XS = sub(){ $value };
1116 }
1117  
1118 2 # definition of mro::get_linear_isa()
1119 2 my $get_linear_isa;
1120 2 require 'mro.pm';
1121 $get_linear_isa = \&mro::get_linear_isa;
1122 2  
1123 *get_linear_isa = $get_linear_isa;
1124 }
1125 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
1126 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
1127 use Scalar::Util ();
1128  
1129 # aliases as public APIs
1130 2 # it must be 'require', not 'use', because Mouse::Meta::Module depends on Mouse::Util
1131 require Mouse::Meta::Module; # for the entities of metaclass cache utilities
1132  
1133 # aliases
1134 2 {
1135 2 *class_of = \&Mouse::Meta::Module::_class_of;
1136 2 *get_metaclass_by_name = \&Mouse::Meta::Module::_get_metaclass_by_name;
1137 2 *get_all_metaclass_instances = \&Mouse::Meta::Module::_get_all_metaclass_instances;
1138 *get_all_metaclass_names = \&Mouse::Meta::Module::_get_all_metaclass_names;
1139 2  
1140 2 *Mouse::load_class = \&load_class;
1141 *Mouse::is_class_loaded = \&is_class_loaded;
1142  
1143 # is-a predicates
1144 #generate_isa_predicate_for('Mouse::Meta::TypeConstraint' => 'is_a_type_constraint');
1145 #generate_isa_predicate_for('Mouse::Meta::Class' => 'is_a_metaclass');
1146 #generate_isa_predicate_for('Mouse::Meta::Role' => 'is_a_metarole');
1147  
1148 2 # duck type predicates
1149 2 generate_can_predicate_for(['_compiled_type_constraint'] => 'is_a_type_constraint');
1150 2 generate_can_predicate_for(['create_anon_class'] => 'is_a_metaclass');
1151 generate_can_predicate_for(['create_anon_role'] => 'is_a_metarole');
1152 }
1153  
1154 sub in_global_destruction;
1155 2 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined ${^GLOBAL_PHASE}) { } 2 0 2
1156 0 ▶if (defined ${^GLOBAL_PHASE}) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1157 0 *in_global_destruction = sub {
1158 2 return ${^GLOBAL_PHASE} eq 'DESTRUCT';
1159 };
1160 }
1161 0 else {
1162 2 ▶ my $in_global_destruction = 0;
Subroutine END: called CC=1 SCAR=0.0
1163 0 ▶ END { $in_global_destruction = 1 }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1164 0 *in_global_destruction = sub {
1165 0 return $in_global_destruction;
1166 };
1167 }
1168  
1169 # Moose::Util compatible utilities
1170 0 ▶ 
Subroutine find_meta: not called CC=1 SCAR=6.9
Pod documented
1171 0 sub find_meta{
1172 return class_of( $_[0] );
1173 }
1174 0 ▶ 
Subroutine _does_role_impl: not called CC=4 SCAR=30.0
1175 0 sub _does_role_impl {
1176 my ($class_or_obj, $role_name) = @_;
1177 0  
1178 my $meta = class_of($class_or_obj);
1179 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
defined $role_name or ($meta || "Mouse::Meta::Class")->throw_error("You must supply a role name to does()") 0 0 0
Condition0%0/2
$meta || 'Mouse::Meta::Class'
l!l
00
MC/DC0%0/1
$meta || 'Mouse::Meta::Class'
$meta
Truth table0%0/2
A
A= $meta
Aresult
11
00
1180 (defined $role_name)
1181 || ($meta || 'Mouse::Meta::Class')->throw_error("You must supply a role name to does()");
1182 0 ▶ 
Condition0%0/3
defined $meta && $meta->does_role($role_name)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $meta && $meta->does_role($role_name)
defined $meta $meta->does_role($role_name)
Truth table0%0/3
A && B
A= defined $metaB= $meta->does_role($role_name)
ABresult
0X0
100
111
1183 return defined($meta) && $meta->does_role($role_name);
1184 }
1185 0 ▶ 
Subroutine does_role: not called CC=4 SCAR=30.0
Pod documented
1186 0 sub does_role {
1187 my($thing, $role_name) = @_;
1188 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($thing) || is_class_loaded($thing) and $thing->can("does")) 0 0 0
Condition0%0/6
builtin::blessed($thing) || is_class_loaded($thing) and $thing->can("does")
!ll&&!rl&&r
000
builtin::blessed($thing) or is_class_loaded($thing)
l!l&&r!l&&!r
000
MC/DC0%0/3
builtin::blessed($thing) || is_class_loaded($thing) and $thing->can("does")
builtin::blessed($thing) is_class_loaded($thing) $thing->can("does")
Truth table0%0/5
A or B and C
A= builtin::blessed($thing)B= is_class_loaded($thing)C= $thing->can("does")
ABCresult
00X0
1X00
0100
1X11
0111
1189 if( (Scalar::Util::blessed($thing) || is_class_loaded($thing))
1190 0 && $thing->can('does')) {
1191 return $thing->does($role_name);
1192 0 }
1193 goto &_does_role_impl;
1194 }
1195  
1196 # taken from Mouse::Util (0.90)
1197 2 {
1198 my %cache;
1199 0 ▶ 
Subroutine resolve_metaclass_alias: not called CC=5 SCAR=34.0
Pod documented
1200 0 sub resolve_metaclass_alias {
1201 my ( $type, $metaclass_name, %options ) = @_;
1202 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
$options{'trait'} ? : 0 0 0
1203 my $cache_key = $type . q{ } . ( $options{trait} ? '-Trait' : '' );
1204 0 ▶ 
Condition0%0/3
$cache{$cache_key}{$metaclass_name} ||= do { my $possible_full_name = join("::", "Mouse::Meta", $type, "Custom", $options{"trait"} ? "Trait" : (), $metaclass_name); my $loaded_class = load_first_existing_class($possible_full_name, $metaclass_name); $loaded_class->can("register_implementation") ? $loaded_class->register_implementation : $loaded_class }
l!l&&r!l&&!r
000
MC/DC0%0/2
$cache{$cache_key}{$metaclass_name} ||= do { my $possible_full_name = join("::", "Mouse::Meta", $type, "Custom", $options{"trait"} ? "Trait" : (), $metaclass_name); my $loaded_class = load_first_existing_class($possible_full_name, $metaclass_name); $loaded_class->can("register_implementation") ? $loaded_class->register_implementation : $loaded_class }
$cache{$cache_key}{$metaclass_name} do { my $possible_full_name = join("::", "Mouse::Meta", $type, "Custom", $options{"trait"} ? "Trait" : (), $metaclass_name); my $loaded_class = load_first_existing_class($possible_full_name, $metaclass_name); $loaded_class->can("register_implementation") ? $loaded_class->register_implementation : $loaded_class }
Truth table0%0/3
A ||= B
A= $cache{$cache_key}{$metaclass_name}B= do { my $possible_full_name = join("::", "Mouse::Meta", $type, "Custom", $options{"trait"} ? "Trait" : (), $metaclass_name); my $loaded_class = load_first_existing_class($possible_full_name, $metaclass_name); $loaded_class->can("register_implementation") ? $loaded_class->register_implementation : $loaded_class }
ABresult
1X1
011
000
1205 return $cache{$cache_key}{$metaclass_name} ||= do{
1206  
1207 0 ▶ my $possible_full_name = join '::',
Branch: 1 branch
BranchTrueFalseTotal
$options{'trait'} ? : 0 0 0
1208 'Mouse::Meta', $type, 'Custom', ($options{trait} ? 'Trait' : ()), $metaclass_name
1209 ;
1210 0  
1211 my $loaded_class = load_first_existing_class(
1212 $possible_full_name,
1213 $metaclass_name
1214 );
1215 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
$loaded_class->can('register_implementation') ? : 0 0 0
1216 $loaded_class->can('register_implementation')
1217 ? $loaded_class->register_implementation
1218 : $loaded_class;
1219 };
1220 }
1221 }
1222  
1223 2 ▶# Taken from Module::Runtime
Subroutine module_notional_filename: called CC=1 SCAR=0.0
Pod undocumented
1224 4 sub module_notional_filename {
1225 my $class = shift;
1226 4  
1227 $class =~ s{::}{/}g;
1228 4  
1229 return $class.'.pm';
1230 }
1231  
1232 # Utilities from Class::MOP
1233  
1234 sub get_code_info;
1235 sub get_code_package;
1236  
1237 sub is_valid_class_name;
1238 sub is_class_loaded;
1239  
1240 0 ▶# taken from Class/MOP.pm
Subroutine load_first_existing_class: not called CC=4 SCAR=30.0
Pod undocumented
1241 0 ▶sub load_first_existing_class {
Branch: 1 branch
BranchTrueFalseTotal
my(@classes) = or return 0 0 0
1242 my @classes = @_
1243 or return;
1244 0  
1245 0 my %exceptions;
1246 0 for my $class (@classes) {
1247 my $e = _try_load_one_class($class);
1248 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($e) { } 0 0 0
1249 0 if ($e) {
1250 $exceptions{$class} = $e;
1251 }
1252 0 else {
1253 return $class;
1254 }
1255 }
1256  
1257 # not found
1258 Carp::confess join(
1259 "\n",
1260 0 map {
1261 0 sprintf( "Could not load class (%s) because : %s",
1262 $_, $exceptions{$_} )
1263 } @classes
1264 );
1265 }
1266  
1267 8 ▶# taken from Class/MOP.pm
Subroutine _try_load_one_class: called CC=4 SCAR=22.6
1268 8 sub _try_load_one_class {
1269 my $class = shift;
1270 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_class_name($class)) 0 8 8
1271 0 ▶ unless ( is_valid_class_name($class) ) {
Branch: 1 branch
BranchTrueFalseTotal
defined $class ? : 0 0 0
1272 0 my $display = defined($class) ? $class : 'undef';
1273 Carp::confess "Invalid class name ($display)";
1274 }
1275 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if is_class_loaded($class) 8 0 8
1276 return '' if is_class_loaded($class);
1277 0  
1278 my $filename = module_notional_filename($class);
1279 0  
1280 0 return do {
1281 0 local $@;
1282 0 eval { require $filename };
1283 $@;
1284 };
1285 }
1286  
1287 8 ▶ 
Subroutine load_class: called CC=2 SCAR=7.0
Pod documented
1288 8 sub load_class {
1289 8 my $class = shift;
1290 8 ▶ my $e = _try_load_one_class($class);
Branch: 1 branch
BranchTrueFalseTotal
if $e 0 8 8
1291 Carp::confess "Could not load class ($class) because : $e" if $e;
1292 8  
1293 return $class;
1294 }
1295  
1296 0 ▶ 
Subroutine apply_all_roles: not called CC=9 SCAR=45.0
Pod documented
1297 0 ▶sub apply_all_roles {
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_[0]) ? : 0 0 0
1298 my $consumer = Scalar::Util::blessed($_[0])
1299 ? $_[0] # instance
1300 : Mouse::Meta::Class->initialize($_[0]); # class or role name
1301 0  
1302 my @roles;
1303  
1304 0 # Basis of Data::OptList
1305 0 ▶ my $max = scalar(@_);
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $max) 0 0 0
1306 0 for (my $i = 1; $i < $max ; $i++) {
1307 0 my $role = $_[$i];
1308 0 ▶ my $role_name;
Branch: 1 branch
BranchTrueFalseTotal
if (ref $role) { } 0 0 0
1309 0 if(ref $role) {
1310 $role_name = $role->name;
1311 }
1312 0 else {
1313 0 $role_name = $role;
1314 0 load_class($role_name);
1315 $role = get_metaclass_by_name($role_name);
1316 }
1317 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($i + 1 < $max and ref $_[$i + 1] eq 'HASH') { } 0 0 0
Condition0%0/3
$i + 1 < $max and ref $_[$i + 1] eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
$i + 1 < $max and ref $_[$i + 1] eq "HASH"
$i + 1 < $max ref $_[$i + 1] eq "HASH"
Truth table0%0/3
A and B
A= $i + 1 < $maxB= ref $_[$i + 1] eq "HASH"
ABresult
0X0
100
111
1318 0 if ($i + 1 < $max && ref($_[$i + 1]) eq 'HASH') {
1319 push @roles, [ $role => $_[++$i] ];
1320 0 } else {
1321 push @roles, [ $role => undef ];
1322 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
is_a_metarole($role) or $consumer->meta->throw_error("You can only consume roles, $role_name is not a Mouse role") 0 0 0
1323 is_a_metarole($role)
1324 || $consumer->meta->throw_error("You can only consume roles, $role_name is not a Mouse role");
1325 }
1326 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @roles == 1) { } 0 0 0
1327 0 if ( scalar @roles == 1 ) {
1328 0 ▶ my ( $role, $params ) = @{ $roles[0] };
Branch: 1 branch
BranchTrueFalseTotal
defined $params ? : 0 0 0
1329 $role->apply( $consumer, defined $params ? $params : () );
1330 }
1331 0 else {
1332 Mouse::Meta::Role->combine(@roles)->apply($consumer);
1333 0 }
1334 return;
1335 }
1336  
1337 0 ▶# taken from Moose::Util 0.90
Subroutine english_list: not called CC=3 SCAR=24.8
Pod undocumented
1338 0 ▶sub english_list {
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 0 0
1339 return $_[0] if @_ == 1;
1340 0  
1341 my @items = sort @_;
1342 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if @items == 2 0 0 0
1343 return "$items[0] and $items[1]" if @items == 2;
1344 0  
1345 my $tail = pop @items;
1346 0  
1347 return join q{, }, @items, "and $tail";
1348 }
1349 0 ▶ 
Subroutine quoted_english_list: not called CC=1 SCAR=6.9
Pod undocumented
1350 0 sub quoted_english_list {
1351 return english_list(map { qq{'$_'} } @_);
1352 }
1353  
1354 # common utilities
1355 0 ▶ 
Subroutine not_supported: not called CC=2 SCAR=17.9
Pod documented
1356 0 sub not_supported{
1357 my($feature) = @_;
1358 0 ▶ 
Condition0%0/2
$feature ||= (caller 1)[3] . '()'
l!l
00
MC/DC0%0/1
$feature ||= (caller 1)[3] . '()'
$feature
Truth table0%0/2
A
A= $feature
Aresult
11
00
1359 $feature ||= ( caller(1) )[3] . '()'; # subroutine name
1360 0  
1361 0 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
1362 Carp::confess("Mouse does not currently support $feature");
1363 }
1364  
1365 0 ▶# general meta() method
Subroutine meta: not called CC=2 SCAR=17.9
Pod undocumented
1366 0 ▶sub meta :method{
Condition0%0/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
1367 return Mouse::Meta::Class->initialize(ref($_[0]) || $_[0]);
1368 }
1369  
1370 # general throw_error() method
1371 0 ▶# $o->throw_error($msg, depth => $leve, longmess => $croak_or_confess)
Subroutine throw_error: not called CC=4 SCAR=30.0
Pod undocumented
1372 0 sub throw_error :method {
1373 my($self, $message, %args) = @_;
1374 0 ▶ 
Condition0%0/2
$args{'depth'} || 0
l!l
00
MC/DC0%0/1
$args{'depth'} || 0
$args{'depth'}
Truth table0%0/2
A
A= $args{'depth'}
Aresult
11
00
1375 0 local $Carp::CarpLevel = $Carp::CarpLevel + 1 + ($args{depth} || 0);
1376 local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though
1377 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{'longmess'} and not $args{'longmess'}) { } 0 0 0
Condition0%0/3
exists $args{"longmess"} and not $args{"longmess"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $args{"longmess"} and not $args{"longmess"}
exists $args{"longmess"} not $args{"longmess"}
Truth table0%0/3
A and not(B)
A= exists $args{"longmess"}B= not $args{"longmess"}
ABresult
0X0
100
111
1378 0 if(exists $args{longmess} && !$args{longmess}) {
1379 Carp::croak($message);
1380 }
1381 0 else{
1382 Carp::confess($message);
1383 }
1384 }
1385  
1386 0 ▶# general dump() method
Subroutine dump: not called CC=2 SCAR=17.9
Pod undocumented
1387 0 sub dump :method {
1388 my($self, $maxdepth) = @_;
1389 0  
1390 0 require 'Data/Dumper.pm'; # we don't want to create its namespace
1391 0 ▶ my $dd = Data::Dumper->new([$self]);
Branch: 1 branch
BranchTrueFalseTotal
defined $maxdepth ? : 0 0 0
1392 0 $dd->Maxdepth(defined($maxdepth) ? $maxdepth : 3);
1393 0 $dd->Indent(1);
1394 0 $dd->Sortkeys(1);
1395 0 $dd->Quotekeys(0);
1396 return $dd->Dump();
1397 }
1398  
1399 0 ▶# general does() method
Subroutine does: not called CC=1 SCAR=6.9
Pod undocumented
1400 0 sub does :method {
1401 goto &_does_role_impl;
1402 }
1403  
1404 }
1405 BEGIN{ # lib/Mouse/Meta/TypeConstraint.pm
1406 2 ▶package Mouse::Meta::TypeConstraint;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
1407 use Mouse::Util qw(:meta); # enables strict and warnings
1408 46 ▶ 
Subroutine new: called CC=17 SCAR=40.6
Pod documented
1409 46 sub new {
1410 0 ▶ my $class = shift;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 46 46
1411 my %args = @_ == 1 ? %{$_[0]} : @_;
1412 46 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"name"} 0 46 46
1413 $args{name} = '__ANON__' if !defined $args{name};
1414 46  
1415 46 ▶ my $type_parameter;
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"parent"}) 44 2 46
1416 44 if(defined $args{parent}) { # subtyping
1417 %args = (%{$args{parent}}, %args);
1418  
1419 # a child type must not inherit 'compiled_type_constraint'
1420 44 # and 'hand_optimized_type_constraint' from the parent
1421 44 delete $args{compiled_type_constraint}; # don't inherit it
1422 delete $args{hand_optimized_type_constraint}; # don't inherit it
1423 44  
1424 44 ▶ $type_parameter = $args{type_parameter};
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $parent_tp = $args{"parent"}{"type_parameter"})) 0 44 44
1425 0 ▶ if(defined(my $parent_tp = $args{parent}{type_parameter})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent_tp != $type_parameter) { } 0 0 0
1426 0 ▶ if($parent_tp != $type_parameter) {
Branch: 1 branch
BranchTrueFalseTotal
$type_parameter->is_a_type_of($parent_tp) or $class->throw_error("$type_parameter is not a subtype of $parent_tp") 0 0 0
1427 $type_parameter->is_a_type_of($parent_tp)
1428 or $class->throw_error(
1429 "$type_parameter is not a subtype of $parent_tp",
1430 );
1431 }
1432 0 else {
1433 $type_parameter = undef;
1434 }
1435 }
1436 }
1437 46  
1438 my $check;
1439 46 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if ($check = delete $args{'optimized'}) { } 40 6 46
elsif (defined $type_parameter) { } 0 6 6
1440 40 if($check = delete $args{optimized}) { # likely to be builtins
1441 40 $args{hand_optimized_type_constraint} = $check;
1442 $args{compiled_type_constraint} = $check;
1443 }
1444 elsif(defined $type_parameter) { # parameterizing
1445 0 ▶ my $generator = $args{constraint_generator}
Condition0%0/3
$args{'constraint_generator'} || $class->throw_error("The $args{'name'} constraint cannot be used," . " because $type_parameter doesn't subtype" . ' from a parameterizable type')
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'constraint_generator'} || $class->throw_error("The $args{'name'} constraint cannot be used," . " because $type_parameter doesn't subtype" . ' from a parameterizable type')
$args{'constraint_generator'} $class->throw_error("The $args{'name'} constraint cannot be used," . " because $type_parameter doesn't subtype" . ' from a parameterizable type')
Truth table0%0/3
A || B
A= $args{'constraint_generator'}B= $class->throw_error("The $args{'name'} constraint cannot be used," . " because $type_parameter doesn't subtype" . ' from a parameterizable type')
ABresult
1X1
011
000
1446 || $class->throw_error(
1447 "The $args{name} constraint cannot be used,"
1448 . " because $type_parameter doesn't subtype"
1449 . " from a parameterizable type");
1450 0  
1451 0 ▶ my $parameterized_check = $generator->($type_parameter);
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $my_check = $args{'constraint'})) { } 0 0 0
1452 0 ▶ if(defined(my $my_check = $args{constraint})) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1453 0 ▶ $check = sub {
Condition0%0/3
&$parameterized_check($_) && &$my_check($_)
!ll&&!rl&&r
000
MC/DC0%0/2
&$parameterized_check($_) && &$my_check($_)
&$parameterized_check($_) &$my_check($_)
Truth table0%0/3
A && B
A= &$parameterized_check($_)B= &$my_check($_)
ABresult
0X0
100
111
1454 0 return $parameterized_check->($_) && $my_check->($_);
1455 };
1456 }
1457 0 else {
1458 $check = $parameterized_check;
1459 0 }
1460 $args{constraint} = $check;
1461 }
1462 6 else { # common cases
1463 $check = $args{constraint};
1464 }
1465 46 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $check and ref $check ne "CODE") 0 46 46
Condition66%2/3
defined $check and ref $check ne "CODE"
!ll&&!rl&&r
6400
MC/DC0%0/2
defined $check and ref $check ne "CODE"
defined $check ref $check ne "CODE"
Truth table66%2/3
A and B
A= defined $checkB= ref $check ne "CODE"
ABresult
0X0
100
111
1466 0 if(defined($check) && ref($check) ne 'CODE'){
1467 $class->throw_error(
1468 "Constraint for $args{name} is not a CODE reference");
1469 }
1470 46  
1471 my $self = bless \%args, $class;
1472 46 ▶ $self->compile_type_constraint()
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"hand_optimized_type_constraint"} 6 40 46
1473 if !$args{hand_optimized_type_constraint};
1474 46 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"type_constraints"}) 0 46 46
1475 0 if($args{type_constraints}) { # union types
1476 0 ▶ foreach my $type(@{$self->{type_constraints}}){
Branch: 1 branch
BranchTrueFalseTotal
if ($type->has_coercion) 0 0 0
1477 if($type->has_coercion){
1478 0 # set undef for has_coercion()
1479 0 $self->{_compiled_type_coercion} = undef;
1480 last;
1481 }
1482 }
1483 }
1484 46  
1485 return $self;
1486 }
1487 0 ▶ 
Subroutine create_child_type: not called CC=1 SCAR=6.9
Pod documented
1488 0 sub create_child_type {
1489 0 my $self = shift;
1490 return ref($self)->new(@_, parent => $self);
1491 }
1492  
1493 sub name;
1494 sub parent;
1495 sub message;
1496 sub has_coercion;
1497  
1498 sub check;
1499  
1500 sub type_parameter;
1501 sub __is_parameterized;
1502  
1503 sub _compiled_type_constraint;
1504 sub _compiled_type_coercion;
1505  
1506 sub compile_type_constraint;
1507  
1508 0 ▶ 
Subroutine _add_type_coercions: not called CC=6 SCAR=37.4
1509 0 sub _add_type_coercions { # ($self, @pairs)
1510 my $self = shift;
1511 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"type_constraints"}) 0 0 0
1512 0 if(exists $self->{type_constraints}){ # union type
1513 $self->throw_error(
1514 "Cannot add additional type coercions to Union types '$self'");
1515 }
1516 0 ▶ 
Condition0%0/2
$self->{"coercion_map"} ||= []
l!l
00
MC/DC0%0/1
$self->{"coercion_map"} ||= []
$self->{"coercion_map"}
Truth table0%0/2
A
A= $self->{"coercion_map"}
Aresult
11
00
1517 0 my $coercion_map = ($self->{coercion_map} ||= []);
1518 my %has = map{ $_->[0]->name => undef } @{$coercion_map};
1519 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 0 0 0
1520 0 for(my $i = 0; $i < @_; $i++){
1521 0 my $from = $_[ $i];
1522 my $action = $_[++$i];
1523 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $has{$from}) 0 0 0
1524 0 if(exists $has{$from}){
1525 $self->throw_error("A coercion action already exists for '$from'");
1526 }
1527 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $type = Mouse::Util::TypeConstraints::find_or_parse_type_constraint($from) or $self->throw_error("Could not find the type constraint ($from) to coerce from") 0 0 0
1528 my $type = Mouse::Util::TypeConstraints::find_or_parse_type_constraint($from)
1529 or $self->throw_error(
1530 "Could not find the type constraint ($from) to coerce from");
1531 0  
1532 push @{$coercion_map}, [ $type => $action ];
1533 }
1534 0  
1535 0 $self->{_compiled_type_coercion} = undef;
1536 return;
1537 }
1538 0 ▶ 
Subroutine _compiled_type_coercion: not called CC=7 SCAR=40.3
1539 0 sub _compiled_type_coercion {
1540 my($self) = @_;
1541 0  
1542 0 ▶ my $coercion = $self->{_compiled_type_coercion};
Branch: 1 branch
BranchTrueFalseTotal
if defined $coercion 0 0 0
1543 return $coercion if defined $coercion;
1544 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'type_constraints'}) { } 0 0 0
1545 0 if(!$self->{type_constraints}) {
1546 0 my @coercions;
1547 0 foreach my $pair(@{$self->{coercion_map}}) {
1548 push @coercions,
1549 [ $pair->[0]->_compiled_type_constraint, $pair->[1] ];
1550 }
1551 0 ▶ 
Subroutine __ANON__: not called CC=4 SCAR=30.0
1552 0 $coercion = sub {
1553 0 my($thing) = @_;
1554 foreach my $pair (@coercions) {
1555 0 ▶ #my ($constraint, $converter) = @$pair;
Branch: 1 branch
BranchTrueFalseTotal
if ($pair->[0]->($thing)) 0 0 0
1556 0 if ($pair->[0]->($thing)) {
1557 return $pair->[1]->($thing) for $thing; # local $_ will cancel tie-ness due to perl's bug
1558 }
1559 0 }
1560 0 return $thing;
1561 };
1562 }
1563 0 else { # for union type
1564 0 my @coercions;
1565 0 ▶ foreach my $type(@{$self->{type_constraints}}){
Branch: 1 branch
BranchTrueFalseTotal
if ($type->has_coercion) 0 0 0
1566 0 if($type->has_coercion){
1567 push @coercions, $type;
1568 }
1569 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
if (@coercions) 0 0 0
1570 0 ▶ if(@coercions){
Subroutine __ANON__: not called CC=3 SCAR=24.8
1571 0 $coercion = sub {
1572 0 my($thing) = @_;
1573 0 foreach my $type(@coercions){
1574 0 ▶ my $value = $type->coerce($thing);
Branch: 1 branch
BranchTrueFalseTotal
if $self->check($value) 0 0 0
1575 return $value if $self->check($value);
1576 0 }
1577 0 return $thing;
1578 };
1579 }
1580 }
1581 0  
1582 return( $self->{_compiled_type_coercion} = $coercion );
1583 }
1584 0 ▶ 
Subroutine coerce: not called CC=3 SCAR=24.8
Pod documented
1585 0 sub coerce {
1586 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if $self->check(@_) 0 0 0
1587 return $_[0] if $self->check(@_);
1588 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $coercion = $self->_compiled_type_coercion or $self->throw_error("Cannot coerce without a type coercion") 0 0 0
1589 my $coercion = $self->_compiled_type_coercion
1590 0 or $self->throw_error("Cannot coerce without a type coercion");
1591 return $coercion->(@_);
1592 }
1593 0 ▶ 
Subroutine get_message: not called CC=6 SCAR=37.4
Pod documented
1594 0 sub get_message {
1595 0 ▶ my ($self, $value) = @_;
Branch: 1 branch
BranchTrueFalseTotal
if (my $msg = $self->message) { } 0 0 0
1596 0 if ( my $msg = $self->message ) {
1597 return $msg->($value) for $value; # local $_ will cancel tie-ness due to perl's bug
1598 }
1599 0 ▶ else {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
elsif (ref $value and defined &overload::StrVal) { } 0 0 0
1600 0 if(not defined $value) {
1601 $value = 'undef';
1602 ▶ }
Condition0%0/3
ref $value and defined &overload::StrVal
!ll&&!rl&&r
000
MC/DC0%0/2
ref $value and defined &overload::StrVal
ref $value defined &overload::StrVal
Truth table0%0/3
A and B
A= ref $valueB= defined &overload::StrVal
ABresult
0X0
100
111
1603 0 elsif( ref($value) && defined(&overload::StrVal) ) {
1604 $value = overload::StrVal($value);
1605 0 }
1606 return "Validation failed for '$self' with value $value";
1607 }
1608 }
1609 0 ▶ 
Subroutine is_a_type_of: not called CC=9 SCAR=45.0
Pod documented
1610 0 sub is_a_type_of {
1611 my($self, $other) = @_;
1612  
1613 0 ▶ # ->is_a_type_of('__ANON__') is always false
Branch: 1 branch
BranchTrueFalseTotal
if not ref $other and $other eq "__ANON__" 0 0 0
Condition0%0/3
not ref $other and $other eq "__ANON__"
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $other and $other eq "__ANON__"
not ref $other $other eq "__ANON__"
Truth table0%0/3
not(A) and B
A= not ref $otherB= $other eq "__ANON__"
ABresult
0X0
100
111
1614 return 0 if !ref($other) && $other eq '__ANON__';
1615 0  
1616 (my $other_name = $other) =~ s/\s+//g;
1617 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $self->name eq $other_name 0 0 0
1618 return 1 if $self->name eq $other_name;
1619 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"type_constraints"}) 0 0 0
1620 0 if(exists $self->{type_constraints}){ # union
1621 0 ▶ foreach my $type(@{$self->{type_constraints}}) {
Branch: 1 branch
BranchTrueFalseTotal
if $type->name eq $other_name 0 0 0
1622 return 1 if $type->name eq $other_name;
1623 }
1624 }
1625 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $p) 0 0 0
1626 0 ▶ for(my $p = $self->parent; defined $p; $p = $p->parent) {
Branch: 1 branch
BranchTrueFalseTotal
if $p->name eq $other_name 0 0 0
1627 return 1 if $p->name eq $other_name;
1628 }
1629 0  
1630 return 0;
1631 }
1632  
1633 0 ▶# See also Moose::Meta::TypeConstraint::Parameterizable
Subroutine parameterize: not called CC=3 SCAR=24.8
Pod undocumented
1634 0 sub parameterize {
1635 my($self, $param, $name) = @_;
1636 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $param) 0 0 0
1637 0 if(!ref $param){
1638 0 require Mouse::Util::TypeConstraints;
1639 $param = Mouse::Util::TypeConstraints::find_or_create_isa_type_constraint($param);
1640 }
1641 0 ▶ 
Condition0%0/3
$name ||= sprintf("%s[%s]", $self->name, $param->name)
l!l&&r!l&&!r
000
MC/DC0%0/2
$name ||= sprintf("%s[%s]", $self->name, $param->name)
$name sprintf("%s[%s]", $self->name, $param->name)
Truth table0%0/3
A ||= B
A= $nameB= sprintf("%s[%s]", $self->name, $param->name)
ABresult
1X1
011
000
1642 0 $name ||= sprintf '%s[%s]', $self->name, $param->name;
1643 return Mouse::Meta::TypeConstraint->new(
1644 name => $name,
1645 parent => $self,
1646 type_parameter => $param,
1647 );
1648 }
1649 0 ▶ 
Subroutine assert_valid: not called CC=2 SCAR=17.9
Pod documented
1650 0 sub assert_valid {
1651 my ($self, $value) = @_;
1652 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->check($value)) 0 0 0
1653 0 if(!$self->check($value)){
1654 $self->throw_error($self->get_message($value));
1655 0 }
1656 return 1;
1657 }
1658  
1659 # overloading stuff
1660 0 ▶ 
Subroutine _as_string: not called CC=1 SCAR=6.9
1661 sub _as_string { $_[0]->name } # overload ""
1662 sub _identity; # overload 0+
1663 0 ▶ 
Subroutine _unite: not called CC=1 SCAR=6.9
1664 0 sub _unite { # overload infix:<|>
1665 0 my($lhs, $rhs) = @_;
1666 0 require Mouse::Util::TypeConstraints;
1667 return Mouse::Util::TypeConstraints::_find_or_create_union_type(
1668 $lhs,
1669 Mouse::Util::TypeConstraints::find_or_create_isa_type_constraint($rhs),
1670 );
1671 }
1672  
1673 2 ▶}
Subroutine BEGIN: called CC=2 SCAR=7.1
1674 BEGIN{ # lib/Mouse/Util/TypeConstraints.pm
1675 2 ▶package Mouse::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
1676 use Mouse::Util; # enables strict and warnings
1677 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
1678 2 ▶use Mouse::Meta::TypeConstraint;
Subroutine BEGIN: called CC=1 SCAR=0.0
1679 use Mouse::Exporter;
1680 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
1681 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
1682 use Scalar::Util ();
1683 2  
1684 Mouse::Exporter->setup_import_methods(
1685 as_is => [qw(
1686 as where message optimize_as
1687 from via
1688  
1689 type subtype class_type role_type maybe_type duck_type
1690 enum
1691 coerce
1692  
1693 find_type_constraint
1694 register_type_constraint
1695 )],
1696 );
1697 2  
1698 our @CARP_NOT = qw(Mouse::Meta::Attribute);
1699 2  
1700 my %TYPE;
1701  
1702 2 # The root type
1703 $TYPE{Any} = Mouse::Meta::TypeConstraint->new(
1704 name => 'Any',
1705 );
1706 2  
1707 my @builtins = (
1708 # $name => $parent, $code,
1709  
1710 # the base type
1711 Item => 'Any', undef,
1712  
1713 # the maybe[] type
1714 Maybe => 'Item', undef,
1715  
1716 # value types
1717 Undef => 'Item', \&Undef,
1718 Defined => 'Item', \&Defined,
1719 Bool => 'Item', \&Bool,
1720 Value => 'Defined', \&Value,
1721 Str => 'Value', \&Str,
1722 Num => 'Str', \&Num,
1723 Int => 'Num', \&Int,
1724  
1725 # ref types
1726 Ref => 'Defined', \&Ref,
1727 ScalarRef => 'Ref', \&ScalarRef,
1728 ArrayRef => 'Ref', \&ArrayRef,
1729 HashRef => 'Ref', \&HashRef,
1730 CodeRef => 'Ref', \&CodeRef,
1731 RegexpRef => 'Ref', \&RegexpRef,
1732 GlobRef => 'Ref', \&GlobRef,
1733  
1734 # object types
1735 FileHandle => 'GlobRef', \&FileHandle,
1736 Object => 'Ref', \&Object,
1737  
1738 # special string types
1739 ClassName => 'Str', \&ClassName,
1740 RoleName => 'ClassName', \&RoleName,
1741 );
1742 2 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@builtins, 0, 3)) 40 2 42
1743 while (my ($name, $parent, $code) = splice @builtins, 0, 3) {
1744 $TYPE{$name} = Mouse::Meta::TypeConstraint->new(
1745 40 name => $name,
1746 parent => $TYPE{$parent},
1747 optimized => $code,
1748 );
1749 }
1750  
1751 2 # parametarizable types
1752 2 $TYPE{Maybe} {constraint_generator} = \&_parameterize_Maybe_for;
1753 2 $TYPE{ArrayRef}{constraint_generator} = \&_parameterize_ArrayRef_for;
1754 $TYPE{HashRef} {constraint_generator} = \&_parameterize_HashRef_for;
1755  
1756 0 ▶# sugars
Subroutine as: not called CC=1 SCAR=6.9
Pod documented
1757 0 ▶sub as ($) { (as => $_[0]) } ## no critic
Subroutine where: not called CC=1 SCAR=6.9
Pod documented
1758 0 ▶sub where (&) { (where => $_[0]) } ## no critic
Subroutine message: not called CC=1 SCAR=6.9
Pod undocumented
1759 0 ▶sub message (&) { (message => $_[0]) } ## no critic
Subroutine optimize_as: not called CC=1 SCAR=6.9
Pod undocumented
1760 sub optimize_as (&) { (optimize_as => $_[0]) } ## no critic
1761 0 ▶ 
Subroutine from: not called CC=1 SCAR=6.9
Pod documented
1762 0 ▶sub from { @_ }
Subroutine via: not called CC=1 SCAR=6.9
Pod documented
1763 sub via (&) { $_[0] } ## no critic
1764  
1765 # type utilities
1766 0 ▶ 
Subroutine optimized_constraints: not called CC=1 SCAR=6.9
Pod undocumented
1767 0 sub optimized_constraints { # DEPRECATED
1768 0 Carp::cluck('optimized_constraints() has been deprecated');
1769 return \%TYPE;
1770 }
1771 2  
1772 2 undef @builtins; # free the allocated memory
1773 0 ▶@builtins = keys %TYPE; # reuse it
Subroutine list_all_builtin_type_constraints: not called CC=1 SCAR=6.9
Pod documented
1774 0 ▶sub list_all_builtin_type_constraints { @builtins }
Subroutine list_all_type_constraints: not called CC=1 SCAR=6.9
Pod documented
1775 sub list_all_type_constraints { keys %TYPE }
1776 4 ▶ 
Subroutine _define_type: called CC=21 SCAR=45.4
1777 4 sub _define_type {
1778 4 my $is_subtype = shift;
1779 my $name;
1780 my %args;
1781 4 ▶ 
Branch: 3 branches
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0]) { } 0 4 4
elsif (@_ == 2 and ref $_[1]) { } 0 4 4
elsif (@_ % 2) { } 4 0 4
Condition33%1/3
@_ == 1 and ref $_[0]
!ll&&!rl&&r
400
MC/DC0%0/2
@_ == 1 and ref $_[0]
@_ == 1 ref $_[0]
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0]
ABresult
0X0
100
111
1782 0 if(@_ == 1 && ref $_[0] ){ # @_ : { name => $name, where => ... }
1783 %args = %{$_[0]};
1784 ▶ }
Condition33%1/3
@_ == 2 and ref $_[1]
!ll&&!rl&&r
400
MC/DC0%0/2
@_ == 2 and ref $_[1]
@_ == 2 ref $_[1]
Truth table33%1/3
A and B
A= @_ == 2B= ref $_[1]
ABresult
0X0
100
111
1785 0 elsif(@_ == 2 && ref $_[1]) { # @_ : $name => { where => ... }
1786 0 $name = $_[0];
1787 %args = %{$_[1]};
1788 }
1789 4 elsif(@_ % 2) { # @_ : $name => ( where => ... )
1790 ($name, %args) = @_;
1791 }
1792 0 else{ # @_ : (name => $name, where => ...)
1793 %args = @_;
1794 }
1795 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 0 4 4
1796 0 if(!defined $name){
1797 $name = $args{name};
1798 }
1799 4  
1800 $args{name} = $name;
1801 4  
1802 4 ▶ my $parent = delete $args{as};
Branch: 1 branch
BranchTrueFalseTotal
if ($is_subtype and not $parent) 0 4 4
Condition33%1/3
$is_subtype and not $parent
!ll&&!rl&&r
040
MC/DC0%0/2
$is_subtype and not $parent
$is_subtype not $parent
Truth table33%1/3
A and not(B)
A= $is_subtypeB= not $parent
ABresult
0X0
100
111
1803 0 if($is_subtype && !$parent){
1804 0 $parent = delete $args{name};
1805 $name = undef;
1806 }
1807 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parent) 4 0 4
1808 4 if(defined $parent) {
1809 $args{parent} = find_or_create_isa_type_constraint($parent);
1810 }
1811 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) 4 0 4
1812 if(defined $name){
1813 4 # set 'package_defined_in' only if it is not a core package
1814 4 ▶ my $this = $args{package_defined_in};
Branch: 1 branch
BranchTrueFalseTotal
unless ($this) 4 0 4
1815 4 if(!$this){
1816 4 ▶ $this = caller(1);
Branch: 1 branch
BranchTrueFalseTotal
unless ($this =~ /\A Mouse \b/msx) 0 4 4
1817 0 if($this !~ /\A Mouse \b/xms){
1818 $args{package_defined_in} = $this;
1819 }
1820 }
1821 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $TYPE{$name}) 0 4 4
1822 0 ▶ if(defined $TYPE{$name}){
Condition0%0/2
$TYPE{$name}{'package_defined_in'} || __PACKAGE__
l!l
00
MC/DC0%0/1
$TYPE{$name}{'package_defined_in'} || __PACKAGE__
$TYPE{$name}{'package_defined_in'}
Truth table0%0/2
A
A= $TYPE{$name}{'package_defined_in'}
Aresult
11
00
1823 0 ▶ my $that = $TYPE{$name}->{package_defined_in} || __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if ($this ne $that) 0 0 0
1824 0 if($this ne $that) {
1825 0 ▶ my $note = '';
Branch: 1 branch
BranchTrueFalseTotal
if ($that eq __PACKAGE__) 0 0 0
1826 if($that eq __PACKAGE__) {
1827 $note = sprintf " ('%s' is %s type constraint)",
1828 0 ▶ $name,
Branch: 1 branch
BranchTrueFalseTotal
scalar grep({$name eq $_;} list_all_builtin_type_constraints()) ? : 0 0 0
1829 scalar(grep { $name eq $_ } list_all_builtin_type_constraints())
1830 ? 'a builtin'
1831 : 'an implicitly created';
1832 0 }
1833 Carp::croak("The type constraint '$name' has already been created in $that"
1834 . " and cannot be created again in $this" . $note);
1835 }
1836 }
1837 }
1838 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"where"} 0 4 4
1839 4 ▶ $args{constraint} = delete $args{where} if exists $args{where};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"optimized_as"} 4 0 4
1840 $args{optimized} = delete $args{optimized_as} if exists $args{optimized_as};
1841 4  
1842 my $constraint = Mouse::Meta::TypeConstraint->new(%args);
1843 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) { } 4 0 4
1844 4 if(defined $name){
1845 return $TYPE{$name} = $constraint;
1846 }
1847 0 else{
1848 return $constraint;
1849 }
1850 }
1851 0 ▶ 
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
1852 0 sub type {
1853 return _define_type 0, @_;
1854 }
1855 4 ▶ 
Subroutine subtype: called CC=1 SCAR=0.0
Pod documented
1856 4 sub subtype {
1857 return _define_type 1, @_;
1858 }
1859 0 ▶ 
Subroutine coerce: not called CC=2 SCAR=17.9
Pod documented
1860 0 sub coerce { # coerce $type, from $from, via { ... }, ...
1861 0 ▶ my $type_name = shift;
Branch: 1 branch
BranchTrueFalseTotal
my $type = find_type_constraint($type_name) or Carp::croak("Cannot find type '${type_name}', perhaps you forgot to load it") 0 0 0
1862 my $type = find_type_constraint($type_name)
1863 or Carp::croak("Cannot find type '$type_name', perhaps you forgot to load it");
1864 0  
1865 0 $type->_add_type_coercions(@_);
1866 return;
1867 }
1868 4 ▶ 
Subroutine class_type: called CC=2 SCAR=7.6
Pod documented
1869 4 sub class_type {
1870 4 ▶ my($name, $options) = @_;
Condition33%1/3
$options->{'class'} || $name
l!l&&r!l&&!r
040
MC/DC0%0/2
$options->{'class'} || $name
$options->{'class'} $name
Truth table33%1/3
A || B
A= $options->{'class'}B= $name
ABresult
1X1
011
000
1871 my $class = $options->{class} || $name;
1872  
1873 4 # ClassType
1874 return subtype $name => (
1875 as => 'Object',
1876 optimized_as => Mouse::Util::generate_isa_predicate_for($class),
1877 class => $class,
1878 );
1879 }
1880 0 ▶ 
Subroutine role_type: not called CC=2 SCAR=17.9
Pod documented
1881 0 sub role_type {
1882 0 ▶ my($name, $options) = @_;
Condition0%0/3
$options->{'role'} || $name
l!l&&r!l&&!r
000
MC/DC0%0/2
$options->{'role'} || $name
$options->{'role'} $name
Truth table0%0/3
A || B
A= $options->{'role'}B= $name
ABresult
1X1
011
000
1883 my $role = $options->{role} || $name;
1884  
1885 # RoleType
1886 return subtype $name => (
1887 0 ▶ as => 'Object',
Subroutine __ANON__: not called CC=2 SCAR=17.9
1888 0 ▶ optimized_as => sub {
Condition0%0/3
builtin::blessed($_[0]) && Mouse::Util::does_role($_[0], $role)
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($_[0]) && Mouse::Util::does_role($_[0], $role)
builtin::blessed($_[0]) Mouse::Util::does_role($_[0], $role)
Truth table0%0/3
A && B
A= builtin::blessed($_[0])B= Mouse::Util::does_role($_[0], $role)
ABresult
0X0
100
111
1889 return Scalar::Util::blessed($_[0])
1890 && Mouse::Util::does_role($_[0], $role);
1891 0 },
1892 role => $role,
1893 );
1894 }
1895 0 ▶ 
Subroutine maybe_type: not called CC=1 SCAR=6.9
Pod undocumented
1896 0 sub maybe_type {
1897 0 my $param = shift;
1898 return _find_or_create_parameterized_type($TYPE{Maybe}, $param);
1899 }
1900 0 ▶ 
Subroutine duck_type: not called CC=4 SCAR=30.0
Pod documented
1901 0 sub duck_type {
1902 my($name, @methods);
1903 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] ne "ARRAY") 0 0 0
1904 0 if(ref($_[0]) ne 'ARRAY'){
1905 $name = shift;
1906 }
1907 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 && ref $_[0] eq 'ARRAY' ? : 0 0 0
Condition0%0/3
@_ == 1 and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1 ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
1908 @methods = (@_ == 1 && ref($_[0]) eq 'ARRAY') ? @{$_[0]} : @_;
1909  
1910 # DuckType
1911 return _define_type 1, $name => (
1912 as => 'Object',
1913 0 ▶ optimized_as => Mouse::Util::generate_can_predicate_for(\@methods),
Subroutine __ANON__: not called CC=1 SCAR=6.9
1914 0 message => sub {
1915 0 my($object) = @_;
1916 0 my @missing = grep { !$object->can($_) } @methods;
1917 return ref($object)
1918 . ' is missing methods '
1919 . Mouse::Util::quoted_english_list(@missing);
1920 0 },
1921 methods => \@methods,
1922 );
1923 }
1924 0 ▶ 
Subroutine enum: not called CC=5 SCAR=34.0
Pod documented
1925 0 sub enum {
1926 my($name, %valid);
1927 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (@_ == 1 and ref $_[0] eq "ARRAY") 0 0 0
Condition0%0/3
@_ == 1 and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1 ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
1928 0 if(!(@_ == 1 && ref($_[0]) eq 'ARRAY')){
1929 $name = shift;
1930 }
1931 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 && ref $_[0] eq 'ARRAY' ? : 0 0 0
Condition0%0/3
@_ == 1 and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1 ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
1932 0 %valid = map{ $_ => undef }
1933 (@_ == 1 && ref($_[0]) eq 'ARRAY' ? @{$_[0]} : @_);
1934  
1935 # EnumType
1936 return _define_type 1, $name => (
1937 0 ▶ as => 'Str',
Subroutine __ANON__: not called CC=3 SCAR=24.8
1938 0 ▶ optimized_as => sub{
Condition0%0/6
defined $_[0] && !ref($_[0]) && exists $valid{$_[0]}
!ll&&!rl&&r
000
defined $_[0] and not ref $_[0]
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_[0] && !ref($_[0]) && exists $valid{$_[0]}
defined $_[0] not ref $_[0] exists $valid{$_[0]}
Truth table0%0/4
A and not(B) && C
A= defined $_[0]B= not ref $_[0]C= exists $valid{$_[0]}
ABCresult
0XX0
10X0
1100
1111
1939 return defined($_[0]) && !ref($_[0]) && exists $valid{$_[0]};
1940 0 },
1941 );
1942 }
1943 0 ▶ 
Subroutine _find_or_create_regular_type: not called CC=5 SCAR=34.0
1944 0 sub _find_or_create_regular_type{
1945 my($spec, $create) = @_;
1946 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if exists $TYPE{$spec} 0 0 0
1947 return $TYPE{$spec} if exists $TYPE{$spec};
1948 0  
1949 my $meta = Mouse::Util::get_metaclass_by_name($spec);
1950 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $meta) 0 0 0
1951 0 ▶ if(!defined $meta){
Branch: 1 branch
BranchTrueFalseTotal
$create ? : 0 0 0
1952 return $create ? class_type($spec) : undef;
1953 }
1954 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (Mouse::Util::is_a_metarole($meta)) { } 0 0 0
1955 0 if(Mouse::Util::is_a_metarole($meta)){
1956 return role_type($spec);
1957 }
1958 0 else{
1959 return class_type($spec);
1960 }
1961 }
1962 0 ▶ 
Subroutine _find_or_create_parameterized_type: not called CC=2 SCAR=17.9
1963 0 sub _find_or_create_parameterized_type{
1964 my($base, $param) = @_;
1965 0  
1966 my $name = sprintf '%s[%s]', $base->name, $param->name;
1967 0 ▶ 
Condition0%0/3
$TYPE{$name} ||= $base->parameterize($param, $name)
l!l&&r!l&&!r
000
MC/DC0%0/2
$TYPE{$name} ||= $base->parameterize($param, $name)
$TYPE{$name} $base->parameterize($param, $name)
Truth table0%0/3
A ||= B
A= $TYPE{$name}B= $base->parameterize($param, $name)
ABresult
1X1
011
000
1968 $TYPE{$name} ||= $base->parameterize($param, $name);
1969 }
1970 0 ▶ 
Subroutine _find_or_create_union_type: not called CC=4 SCAR=30.0
1971 0 ▶sub _find_or_create_union_type{
Branch: 1 branch
BranchTrueFalseTotal
if grep {not defined $_;} @_ 0 0 0
1972 return if grep{ not defined } @_; # all things must be defined
1973 0 ▶ my @types = sort
Branch: 1 branch
BranchTrueFalseTotal
$_->{'type_constraints'} ? : 0 0 0
1974 map{ $_->{type_constraints} ? @{$_->{type_constraints}} : $_ } @_;
1975 0  
1976 my $name = join '|', @types;
1977  
1978 0 ▶ # UnionType
Condition0%0/3
$TYPE{$name} ||= "Mouse::Meta::TypeConstraint"->new("name", $name, "type_constraints", \@types)
l!l&&r!l&&!r
000
MC/DC0%0/2
$TYPE{$name} ||= "Mouse::Meta::TypeConstraint"->new("name", $name, "type_constraints", \@types)
$TYPE{$name} "Mouse::Meta::TypeConstraint"->new("name", $name, "type_constraints", \@types)
Truth table0%0/3
A ||= B
A= $TYPE{$name}B= "Mouse::Meta::TypeConstraint"->new("name", $name, "type_constraints", \@types)
ABresult
1X1
011
000
1979 $TYPE{$name} ||= Mouse::Meta::TypeConstraint->new(
1980 name => $name,
1981 type_constraints => \@types,
1982 );
1983 }
1984  
1985 # The type parser
1986  
1987 0 ▶# param : '[' type ']' | NOTHING
Subroutine _parse_param: not called CC=3 SCAR=24.8
1988 0 sub _parse_param {
1989 my($c) = @_;
1990 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{"spec"} =~ s/^\[//) 0 0 0
1991 0 if($c->{spec} =~ s/^\[//){
1992 my $type = _parse_type($c, 1);
1993 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{"spec"} =~ s/^\]//) 0 0 0
1994 0 if($c->{spec} =~ s/^\]//){
1995 return $type;
1996 0 }
1997 Carp::croak("Syntax error in type: missing right square bracket in '$c->{orig}'");
1998 }
1999 0  
2000 return undef;
2001 }
2002  
2003 0 ▶# name : [\w.:]+
Subroutine _parse_name: not called CC=2 SCAR=17.9
2004 0 sub _parse_name {
2005 my($c, $create) = @_;
2006 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{"spec"} =~ s/\A ([\w.:]+) //msx) 0 0 0
2007 0 if($c->{spec} =~ s/\A ([\w.:]+) //xms){
2008 return _find_or_create_regular_type($1, $create);
2009 0 }
2010 Carp::croak("Syntax error in type: expect type name near '$c->{spec}' in '$c->{orig}'");
2011 }
2012  
2013 0 ▶# single_type : name param
Subroutine _parse_single_type: not called CC=4 SCAR=30.0
2014 0 sub _parse_single_type {
2015 my($c, $create) = @_;
2016 0  
2017 0 my $type = _parse_name($c, $create);
2018 my $param = _parse_param($c);
2019 0 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if (defined $type) { } 0 0 0
elsif (defined $param) { } 0 0 0
2020 0 ▶ if(defined $type){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $param) { } 0 0 0
2021 0 if(defined $param){
2022 return _find_or_create_parameterized_type($type, $param);
2023 }
2024 0 else {
2025 return $type;
2026 }
2027 }
2028 0 elsif(defined $param){
2029 Carp::croak("Undefined type with parameter [$param] in '$c->{orig}'");
2030 }
2031 0 else{
2032 return undef;
2033 }
2034 }
2035  
2036 0 ▶# type : single_type ('|' single_type)*
Subroutine _parse_type: not called CC=4 SCAR=30.0
2037 0 sub _parse_type {
2038 my($c, $create) = @_;
2039 0  
2040 0 ▶ my $type = _parse_single_type($c, $create);
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{"spec"}) 0 0 0
2041 0 if($c->{spec}){ # can be an union type
2042 0 ▶ my @types;
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{"spec"} =~ s/^\|//) 0 0 0
2043 0 while($c->{spec} =~ s/^\|//){
2044 push @types, _parse_single_type($c, $create);
2045 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
if (@types) 0 0 0
2046 0 if(@types){
2047 return _find_or_create_union_type($type, @types);
2048 }
2049 0 }
2050 return $type;
2051 }
2052  
2053 4 ▶ 
Subroutine find_type_constraint: called CC=3 SCAR=12.0
Pod documented
2054 4 sub find_type_constraint {
2055 4 ▶ my($spec) = @_;
Branch: 1 branch
BranchTrueFalseTotal
if Mouse::Util::is_a_type_constraint($spec) or not defined $spec 0 4 4
Condition33%1/3
Mouse::Util::is_a_type_constraint($spec) or not defined $spec
l!l&&r!l&&!r
004
MC/DC0%0/2
Mouse::Util::is_a_type_constraint($spec) or not defined $spec
Mouse::Util::is_a_type_constraint($spec) not defined $spec
Truth table33%1/3
A or not(B)
A= Mouse::Util::is_a_type_constraint($spec)B= not defined $spec
ABresult
1X1
011
000
2056 return $spec if Mouse::Util::is_a_type_constraint($spec) or not defined $spec;
2057 4  
2058 4 $spec =~ s/\s+//g;
2059 return $TYPE{$spec};
2060 }
2061 0 ▶ 
Subroutine register_type_constraint: not called CC=2 SCAR=17.9
Pod undocumented
2062 0 sub register_type_constraint {
2063 0 ▶ my($constraint) = @_;
Branch: 1 branch
BranchTrueFalseTotal
unless Mouse::Util::is_a_type_constraint($constraint) 0 0 0
2064 Carp::croak("No type supplied / type is not a valid type constraint")
2065 0 unless Mouse::Util::is_a_type_constraint($constraint);
2066 return $TYPE{$constraint->name} = $constraint;
2067 }
2068 4 ▶ 
Subroutine find_or_parse_type_constraint: called CC=5 SCAR=22.1
Pod undocumented
2069 4 sub find_or_parse_type_constraint {
2070 4 ▶ my($spec) = @_;
Branch: 1 branch
BranchTrueFalseTotal
if Mouse::Util::is_a_type_constraint($spec) or not defined $spec 0 4 4
Condition33%1/3
Mouse::Util::is_a_type_constraint($spec) or not defined $spec
l!l&&r!l&&!r
004
MC/DC0%0/2
Mouse::Util::is_a_type_constraint($spec) or not defined $spec
Mouse::Util::is_a_type_constraint($spec) not defined $spec
Truth table33%1/3
A or not(B)
A= Mouse::Util::is_a_type_constraint($spec)B= not defined $spec
ABresult
1X1
011
000
2071 return $spec if Mouse::Util::is_a_type_constraint($spec) or not defined $spec;
2072 4  
2073 $spec =~ tr/ \t\r\n//d;
2074 4  
2075 4 ▶ my $tc = $TYPE{$spec};
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tc) 4 0 4
2076 4 if(defined $tc) {
2077 return $tc;
2078 }
2079 0  
2080 my %context = (
2081 spec => $spec,
2082 orig => $spec,
2083 0 );
2084 $tc = _parse_type(\%context);
2085 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($context{"spec"}) 0 0 0
2086 0 if($context{spec}){
2087 Carp::croak("Syntax error: extra elements '$context{spec}' in '$context{orig}'");
2088 }
2089 0  
2090 return $TYPE{$spec} = $tc;
2091 }
2092 0 ▶ 
Subroutine find_or_create_does_type_constraint: not called CC=2 SCAR=17.9
Pod undocumented
2093 sub find_or_create_does_type_constraint{
2094 0 # XXX: Moose does not register a new role_type, but Mouse does.
2095 0 ▶ my $tc = find_or_parse_type_constraint(@_);
Branch: 1 branch
BranchTrueFalseTotal
defined $tc ? : 0 0 0
2096 return defined($tc) ? $tc : role_type(@_);
2097 }
2098 4 ▶ 
Subroutine find_or_create_isa_type_constraint: called CC=2 SCAR=7.2
Pod undocumented
2099 sub find_or_create_isa_type_constraint {
2100 4 # XXX: Moose does not register a new class_type, but Mouse does.
2101 4 ▶ my $tc = find_or_parse_type_constraint(@_);
Branch: 1 branch
BranchTrueFalseTotal
defined $tc ? : 4 0 4
2102 return defined($tc) ? $tc : class_type(@_);
2103 }
2104  
2105 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.6
2106 BEGIN{ # lib/Mouse.pm
2107 2 ▶package Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
2108 use 5.008_005;
2109 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
2110 use Mouse::Exporter; # enables strict and warnings
2111 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
2112 use version; our $VERSION = version->declare('v2.6.2');
2113 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
2114 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
2115 use Scalar::Util ();
2116 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
2117 use Mouse::Util ();
2118 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
2119 2 ▶use Mouse::Meta::Module;
Subroutine BEGIN: called CC=1 SCAR=0.0
2120 2 ▶use Mouse::Meta::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
2121 2 ▶use Mouse::Meta::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
2122 2 ▶use Mouse::Meta::Attribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
2123 2 ▶use Mouse::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
2124 use Mouse::Util::TypeConstraints ();
2125 2  
2126 Mouse::Exporter->setup_import_methods(
2127 as_is => [qw(
2128 extends with
2129 has
2130 before after around
2131 override super
2132 augment inner
2133 ),
2134 \&Scalar::Util::blessed,
2135 \&Carp::confess,
2136 ],
2137 );
2138  
2139 0 ▶ 
Subroutine extends: not called CC=1 SCAR=6.9
Pod documented
2140 0 sub extends {
2141 0 Mouse::Meta::Class->initialize(scalar caller)->superclasses(@_);
2142 return;
2143 }
2144 0 ▶ 
Subroutine with: not called CC=1 SCAR=6.9
Pod undocumented
2145 0 sub with {
2146 0 Mouse::Util::apply_all_roles(scalar(caller), @_);
2147 return;
2148 }
2149 4 ▶ 
Subroutine has: called CC=4 SCAR=14.6
Pod documented
2150 4 sub has {
2151 4 my $meta = Mouse::Meta::Class->initialize(scalar caller);
2152 my $name = shift;
2153 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 0 4 4
2154 $meta->throw_error(q{Usage: has 'name' => ( key => value, ... )})
2155 if @_ % 2; # odd number of arguments
2156 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
ref $name ? : 0 4 4
2157 4 for my $n(ref($name) ? @{$name} : $name){
2158 $meta->add_attribute($n => @_);
2159 4 }
2160 return;
2161 }
2162 0 ▶ 
Subroutine before: not called CC=2 SCAR=17.9
Pod documented
2163 0 sub before {
2164 0 my $meta = Mouse::Meta::Class->initialize(scalar caller);
2165 0 my $code = pop;
2166 0 for my $name($meta->_collect_methods(@_)) {
2167 $meta->add_before_method_modifier($name => $code);
2168 0 }
2169 return;
2170 }
2171 0 ▶ 
Subroutine after: not called CC=2 SCAR=17.9
Pod documented
2172 0 sub after {
2173 0 my $meta = Mouse::Meta::Class->initialize(scalar caller);
2174 0 my $code = pop;
2175 0 for my $name($meta->_collect_methods(@_)) {
2176 $meta->add_after_method_modifier($name => $code);
2177 0 }
2178 return;
2179 }
2180 0 ▶ 
Subroutine around: not called CC=2 SCAR=17.9
Pod documented
2181 0 sub around {
2182 0 my $meta = Mouse::Meta::Class->initialize(scalar caller);
2183 0 my $code = pop;
2184 0 for my $name($meta->_collect_methods(@_)) {
2185 $meta->add_around_method_modifier($name => $code);
2186 0 }
2187 return;
2188 }
2189 2  
2190 2 our $SUPER_PACKAGE;
2191 2 our $SUPER_BODY;
2192 our @SUPER_ARGS;
2193 0 ▶ 
Subroutine super: not called CC=4 SCAR=30.0
Pod undocumented
2194 sub super {
2195 # This check avoids a recursion loop - see
2196 0 ▶ # t/100_bugs/020_super_recursion.t
Branch: 1 branch
BranchTrueFalseTotal
if defined $Mouse::SUPER_PACKAGE and $Mouse::SUPER_PACKAGE ne caller() 0 0 0
Condition0%0/3
defined $Mouse::SUPER_PACKAGE and $Mouse::SUPER_PACKAGE ne caller()
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Mouse::SUPER_PACKAGE and $Mouse::SUPER_PACKAGE ne caller()
defined $Mouse::SUPER_PACKAGE $Mouse::SUPER_PACKAGE ne caller()
Truth table0%0/3
A and B
A= defined $Mouse::SUPER_PACKAGEB= $Mouse::SUPER_PACKAGE ne caller()
ABresult
0X0
100
111
2197 0 ▶ return if defined $SUPER_PACKAGE && $SUPER_PACKAGE ne caller();
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Mouse::SUPER_BODY 0 0 0
2198 0 return if !defined $SUPER_BODY;
2199 $SUPER_BODY->(@SUPER_ARGS);
2200 }
2201 0 ▶ 
Subroutine override: not called CC=1 SCAR=6.9
Pod undocumented
2202 sub override {
2203 0 # my($name, $method) = @_;
2204 Mouse::Meta::Class->initialize(scalar caller)->add_override_method_modifier(@_);
2205 }
2206 2  
2207 2 our %INNER_BODY;
2208 our %INNER_ARGS;
2209 0 ▶ 
Subroutine inner: not called CC=2 SCAR=17.9
Pod undocumented
2210 0 sub inner {
2211 0 ▶ my $pkg = caller();
Branch: 1 branch
BranchTrueFalseTotal
if (my $body = $Mouse::INNER_BODY{$pkg}) { } 0 0 0
2212 0 if ( my $body = $INNER_BODY{$pkg} ) {
2213 0 my $args = $INNER_ARGS{$pkg};
2214 0 local $INNER_ARGS{$pkg};
2215 0 local $INNER_BODY{$pkg};
2216 return $body->(@{$args});
2217 }
2218 0 else {
2219 return;
2220 }
2221 }
2222 0 ▶ 
Subroutine augment: not called CC=1 SCAR=6.9
Pod undocumented
2223 sub augment {
2224 0 #my($name, $method) = @_;
2225 0 Mouse::Meta::Class->initialize(scalar caller)->add_augment_method_modifier(@_);
2226 return;
2227 }
2228 4 ▶ 
Subroutine init_meta: called CC=7 SCAR=21.0
Pod undocumented
2229 4 sub init_meta {
2230 4 shift;
2231 my %args = @_;
2232  
2233 4 ▶ my $class = $args{for_class}
Branch: 1 branch
BranchTrueFalseTotal
my $class = $args{"for_class"} or confess("Cannot call init_meta without specifying a for_class") 4 0 4
2234 or confess("Cannot call init_meta without specifying a for_class");
2235 4 ▶ 
Condition50%1/2
$args{'base_class'} || 'Mouse::Object'
l!l
04
MC/DC0%0/1
$args{'base_class'} || 'Mouse::Object'
$args{'base_class'}
Truth table50%1/2
A
A= $args{'base_class'}
Aresult
11
00
2236 4 ▶ my $base_class = $args{base_class} || 'Mouse::Object';
Condition50%1/2
$args{'metaclass'} || 'Mouse::Meta::Class'
l!l
04
MC/DC0%0/1
$args{'metaclass'} || 'Mouse::Meta::Class'
$args{'metaclass'}
Truth table50%1/2
A
A= $args{'metaclass'}
Aresult
11
00
2237 my $metaclass = $args{metaclass} || 'Mouse::Meta::Class';
2238 4  
2239 4 my $meta = $metaclass->initialize($class);
2240 my $filename = Mouse::Util::module_notional_filename($meta->name);
2241 4 ▶ $INC{$filename} = '(set by Mouse)'
Branch: 1 branch
BranchTrueFalseTotal
unless exists $INC{$filename} 4 0 4
2242 unless exists $INC{$filename};
2243 4 ▶ 
Subroutine __ANON__: called CC=2 SCAR=9.2
2244 4 ▶ $meta->add_method(meta => sub{
Condition33%1/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
040
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
2245 4 return $metaclass->initialize(ref($_[0]) || $_[0]);
2246 });
2247 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless $meta->superclasses 4 0 4
2248 $meta->superclasses($base_class)
2249 unless $meta->superclasses;
2250  
2251 4 ▶ # make a class type for each Mouse class
Branch: 1 branch
BranchTrueFalseTotal
unless Mouse::Util::TypeConstraints::find_type_constraint($class) 4 0 4
2252 Mouse::Util::TypeConstraints::class_type($class)
2253 unless Mouse::Util::TypeConstraints::find_type_constraint($class);
2254 4  
2255 return $meta;
2256 }
2257  
2258 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
2259 BEGIN{ # lib/Mouse/Meta/Attribute.pm
2260 2 ▶package Mouse::Meta::Attribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
2261 use Mouse::Util qw(:meta); # enables strict and warnings
2262 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
2263 use Carp ();
2264 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
2265 use Mouse::Meta::TypeConstraint;
2266 2  
2267 my %valid_options = map { $_ => undef } (
2268 'accessor',
2269 'auto_deref',
2270 'builder',
2271 'clearer',
2272 'coerce',
2273 'default',
2274 'documentation',
2275 'does',
2276 'handles',
2277 'init_arg',
2278 'insertion_order',
2279 'is',
2280 'isa',
2281 'lazy',
2282 'lazy_build',
2283 'name',
2284 'predicate',
2285 'reader',
2286 'required',
2287 'traits',
2288 'trigger',
2289 'type_constraint',
2290 'weak_ref',
2291 'writer',
2292  
2293 # internally used
2294 'associated_class',
2295 'associated_methods',
2296 '__METACLASS__',
2297  
2298 # Moose defines, but Mouse doesn't
2299 #'definition_context',
2300 #'initializer',
2301  
2302 # special case for AttributeHelpers
2303 'provides',
2304 'curries',
2305 );
2306 2  
2307 our @CARP_NOT = qw(Mouse::Meta::Class);
2308 4 ▶ 
Subroutine new: called CC=5 SCAR=19.5
Pod documented
2309 4 sub new {
2310 4 my $class = shift;
2311 my $name = shift;
2312 4  
2313 my $args = $class->Mouse::Object::BUILDARGS(@_);
2314 4  
2315 $class->_process_options($name, $args);
2316 4  
2317 $args->{name} = $name;
2318  
2319 # check options
2320 4 # (1) known by core
2321 my @bad = grep{ !exists $valid_options{$_} } keys %{$args};
2322  
2323 4 ▶ # (2) known by subclasses
Branch: 1 branch
BranchTrueFalseTotal
if (@bad and $class ne __PACKAGE__) 0 4 4
Condition33%1/3
@bad and $class ne __PACKAGE__
!ll&&!rl&&r
400
MC/DC0%0/2
@bad and $class ne __PACKAGE__
@bad $class ne __PACKAGE__
Truth table33%1/3
A and B
A= @badB= $class ne __PACKAGE__
ABresult
0X0
100
111
2324 if(@bad && $class ne __PACKAGE__){
2325 0 my %valid_attrs = (
2326 0 map { $_ => undef }
2327 0 grep { defined }
2328 map { $_->init_arg() }
2329 $class->meta->get_all_attributes()
2330 0 );
2331 @bad = grep{ !exists $valid_attrs{$_} } @bad;
2332 }
2333  
2334 4 ▶ # (3) bad options found
Branch: 1 branch
BranchTrueFalseTotal
if (@bad) 0 4 4
2335 0 if(@bad){
2336 Carp::carp(
2337 "Found unknown argument(s) passed to '$name' attribute constructor in '$class': "
2338 . Mouse::Util::english_list(@bad));
2339 }
2340 4  
2341 4 ▶ my $self = bless $args, $class;
Branch: 1 branch
BranchTrueFalseTotal
if ($class ne __PACKAGE__) 0 4 4
2342 0 if($class ne __PACKAGE__){
2343 $class->meta->_initialize_object($self, $args);
2344 4 }
2345 return $self;
2346 }
2347 0 ▶ 
Subroutine has_read_method: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->has_reader or $_[0]->has_accessor 0 0 0
2348 0 ▶sub has_read_method { $_[0]->has_reader || $_[0]->has_accessor }
Subroutine has_write_method: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->has_writer or $_[0]->has_accessor 0 0 0
2349 sub has_write_method { $_[0]->has_writer || $_[0]->has_accessor }
2350 0 ▶ 
Subroutine get_read_method: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->reader or $_[0]->accessor 0 0 0
2351 0 ▶sub get_read_method { $_[0]->reader || $_[0]->accessor }
Subroutine get_write_method: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->writer or $_[0]->accessor 0 0 0
2352 sub get_write_method { $_[0]->writer || $_[0]->accessor }
2353 0 ▶ 
Subroutine get_read_method_ref: not called CC=2 SCAR=17.9
Pod documented
2354 0 sub get_read_method_ref{
2355 my($self) = @_;
2356 0 ▶ return $self->{_mouse_cache_read_method_ref}
Condition0%0/3
$self->{"_mouse_cache_read_method_ref"} ||= $self->_get_accessor_method_ref("get_read_method", "_generate_reader")
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_mouse_cache_read_method_ref"} ||= $self->_get_accessor_method_ref("get_read_method", "_generate_reader")
$self->{"_mouse_cache_read_method_ref"} $self->_get_accessor_method_ref("get_read_method", "_generate_reader")
Truth table0%0/3
A ||= B
A= $self->{"_mouse_cache_read_method_ref"}B= $self->_get_accessor_method_ref("get_read_method", "_generate_reader")
ABresult
1X1
011
000
2357 ||= $self->_get_accessor_method_ref('get_read_method', '_generate_reader');
2358 }
2359 0 ▶ 
Subroutine get_write_method_ref: not called CC=2 SCAR=17.9
Pod documented
2360 0 sub get_write_method_ref{
2361 my($self) = @_;
2362 0 ▶ return $self->{_mouse_cache_write_method_ref}
Condition0%0/3
$self->{"_mouse_cache_write_method_ref"} ||= $self->_get_accessor_method_ref("get_write_method", "_generate_writer")
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_mouse_cache_write_method_ref"} ||= $self->_get_accessor_method_ref("get_write_method", "_generate_writer")
$self->{"_mouse_cache_write_method_ref"} $self->_get_accessor_method_ref("get_write_method", "_generate_writer")
Truth table0%0/3
A ||= B
A= $self->{"_mouse_cache_write_method_ref"}B= $self->_get_accessor_method_ref("get_write_method", "_generate_writer")
ABresult
1X1
011
000
2363 ||= $self->_get_accessor_method_ref('get_write_method', '_generate_writer');
2364 }
2365 4 ▶ 
Subroutine interpolate_class: called CC=7 SCAR=32.6
Pod undocumented
2366 4 sub interpolate_class{
2367 my($class, $args) = @_;
2368 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (my $metaclass = delete $args->{"metaclass"}) 0 4 4
2369 0 if(my $metaclass = delete $args->{metaclass}){
2370 $class = Mouse::Util::resolve_metaclass_alias( Attribute => $metaclass );
2371 }
2372 4  
2373 4 ▶ my @traits;
Branch: 1 branch
BranchTrueFalseTotal
if (my $traits_ref = delete $args->{"traits"}) 0 4 4
2374 if(my $traits_ref = delete $args->{traits}){
2375 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$traits_ref;}) 0 0 0
2376 0 for (my $i = 0; $i < @{$traits_ref}; $i++) {
2377 my $trait = Mouse::Util::resolve_metaclass_alias(Attribute => $traits_ref->[$i], trait => 1);
2378 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $class->does($trait) 0 0 0
2379 next if $class->does($trait);
2380 0  
2381 push @traits, $trait;
2382  
2383 0 ▶ # are there options?
Branch: 1 branch
BranchTrueFalseTotal
if ref $$traits_ref[$i + 1] 0 0 0
2384 push @traits, $traits_ref->[++$i]
2385 if ref($traits_ref->[$i+1]);
2386 }
2387 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (@traits) 0 0 0
2388 0 if (@traits) {
2389 $class = Mouse::Meta::Class->create_anon_class(
2390 superclasses => [ $class ],
2391 roles => \@traits,
2392 cache => 1,
2393 )->name;
2394 }
2395 }
2396 4  
2397 return( $class, @traits );
2398 }
2399 0 ▶ 
Subroutine verify_against_type_constraint: not called CC=3 SCAR=24.8
Pod documented
2400 0 sub verify_against_type_constraint {
2401 my ($self, $value) = @_;
2402 0  
2403 0 ▶ my $type_constraint = $self->{type_constraint};
Branch: 1 branch
BranchTrueFalseTotal
unless $type_constraint 0 0 0
2404 0 ▶ return 1 if !$type_constraint;
Branch: 1 branch
BranchTrueFalseTotal
if $type_constraint->check($value) 0 0 0
2405 return 1 if $type_constraint->check($value);
2406 0  
2407 $self->_throw_type_constraint_error($value, $type_constraint);
2408 }
2409 0 ▶ 
Subroutine _throw_type_constraint_error: not called CC=1 SCAR=6.9
2410 0 sub _throw_type_constraint_error {
2411 my($self, $value, $type) = @_;
2412 0  
2413 $self->throw_error(
2414 sprintf q{Attribute (%s) does not pass the type constraint because: %s},
2415 $self->name,
2416 $type->get_message($value),
2417 );
2418 }
2419 0 ▶ 
Subroutine illegal_options_for_inheritance: not called CC=1 SCAR=6.9
Pod undocumented
2420 0 sub illegal_options_for_inheritance {
2421 return qw(reader writer accessor clearer predicate);
2422 }
2423 0 ▶ 
Subroutine clone_and_inherit_options: not called CC=10 SCAR=47.0
Pod documented
2424 0 sub clone_and_inherit_options{
2425 0 my $self = shift;
2426 my $args = $self->Mouse::Object::BUILDARGS(@_);
2427 0  
2428 0 ▶ foreach my $illegal($self->illegal_options_for_inheritance) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{$illegal} and exists $self->{$illegal}) 0 0 0
Condition0%0/3
exists $args->{$illegal} and exists $self->{$illegal}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $args->{$illegal} and exists $self->{$illegal}
exists $args->{$illegal} exists $self->{$illegal}
Truth table0%0/3
A and B
A= exists $args->{$illegal}B= exists $self->{$illegal}
ABresult
0X0
100
111
2429 0 if(exists $args->{$illegal} and exists $self->{$illegal}) {
2430 $self->throw_error("Illegal inherited option: $illegal");
2431 }
2432 }
2433 0  
2434 0 ▶ foreach my $name(keys %{$self}){
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args->{$name}) 0 0 0
2435 0 if(!exists $args->{$name}){
2436 $args->{$name} = $self->{$name}; # inherit from self
2437 }
2438 }
2439 0  
2440 0 ▶ my($attribute_class, @traits) = ref($self)->interpolate_class($args);
Branch: 1 branch
BranchTrueFalseTotal
if @traits 0 0 0
2441 $args->{traits} = \@traits if @traits;
2442  
2443 0 # remove temporary caches
2444 0 ▶ foreach my $attr(keys %{$args}){
Branch: 1 branch
BranchTrueFalseTotal
if ($attr =~ /\A _mouse_cache_/msx) 0 0 0
2445 0 if($attr =~ /\A _mouse_cache_/xms){
2446 delete $args->{$attr};
2447 }
2448 }
2449  
2450 0 ▶ # remove default if lazy_build => 1
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"lazy_build"}) 0 0 0
2451 0 if($args->{lazy_build}) {
2452 delete $args->{default};
2453 }
2454 0  
2455 return $attribute_class->new($self->name, $args);
2456 }
2457  
2458 0 ▶ 
Subroutine _get_accessor_method_ref: not called CC=3 SCAR=24.8
2459 0 sub _get_accessor_method_ref {
2460 my($self, $type, $generator) = @_;
2461 0 ▶ 
Condition0%0/3
$self->associated_class || $self->throw_error('No asocciated class for ' . $self->name)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->associated_class || $self->throw_error('No asocciated class for ' . $self->name)
$self->associated_class $self->throw_error('No asocciated class for ' . $self->name)
Truth table0%0/3
A || B
A= $self->associated_classB= $self->throw_error('No asocciated class for ' . $self->name)
ABresult
1X1
011
000
2462 my $metaclass = $self->associated_class
2463 || $self->throw_error('No asocciated class for ' . $self->name);
2464 0  
2465 0 ▶ my $accessor = $self->$type();
Branch: 1 branch
BranchTrueFalseTotal
if ($accessor) { } 0 0 0
2466 0 if($accessor){
2467 return $metaclass->get_method_body($accessor);
2468 }
2469 0 else{
2470 return $self->accessor_metaclass->$generator($self, $metaclass);
2471 }
2472 }
2473 0 ▶ 
Subroutine set_value: not called CC=1 SCAR=6.9
Pod undocumented
2474 0 sub set_value {
2475 0 my($self, $object, $value) = @_;
2476 return $self->get_write_method_ref()->($object, $value);
2477 }
2478 0 ▶ 
Subroutine get_value: not called CC=1 SCAR=6.9
Pod undocumented
2479 0 sub get_value {
2480 0 my($self, $object) = @_;
2481 return $self->get_read_method_ref()->($object);
2482 }
2483 0 ▶ 
Subroutine has_value: not called CC=2 SCAR=17.9
Pod undocumented
2484 0 sub has_value {
2485 my($self, $object) = @_;
2486 0 ▶ my $accessor_ref = $self->{_mouse_cache_predicate_ref}
Condition0%0/3
$self->{"_mouse_cache_predicate_ref"} ||= $self->_get_accessor_method_ref("predicate", "_generate_predicate")
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_mouse_cache_predicate_ref"} ||= $self->_get_accessor_method_ref("predicate", "_generate_predicate")
$self->{"_mouse_cache_predicate_ref"} $self->_get_accessor_method_ref("predicate", "_generate_predicate")
Truth table0%0/3
A ||= B
A= $self->{"_mouse_cache_predicate_ref"}B= $self->_get_accessor_method_ref("predicate", "_generate_predicate")
ABresult
1X1
011
000
2487 ||= $self->_get_accessor_method_ref('predicate', '_generate_predicate');
2488 0  
2489 return $accessor_ref->($object);
2490 }
2491 0 ▶ 
Subroutine clear_value: not called CC=2 SCAR=17.9
Pod undocumented
2492 0 sub clear_value {
2493 my($self, $object) = @_;
2494 0 ▶ my $accessor_ref = $self->{_mouse_cache_crealer_ref}
Condition0%0/3
$self->{"_mouse_cache_crealer_ref"} ||= $self->_get_accessor_method_ref("clearer", "_generate_clearer")
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_mouse_cache_crealer_ref"} ||= $self->_get_accessor_method_ref("clearer", "_generate_clearer")
$self->{"_mouse_cache_crealer_ref"} $self->_get_accessor_method_ref("clearer", "_generate_clearer")
Truth table0%0/3
A ||= B
A= $self->{"_mouse_cache_crealer_ref"}B= $self->_get_accessor_method_ref("clearer", "_generate_clearer")
ABresult
1X1
011
000
2495 ||= $self->_get_accessor_method_ref('clearer', '_generate_clearer');
2496 0  
2497 return $accessor_ref->($object);
2498 }
2499 4 ▶ 
Subroutine associate_method: called CC=1 SCAR=0.0
Pod documented
2500 sub associate_method{
2501 4 #my($attribute, $method_name) = @_;
2502 4 my($attribute) = @_;
2503 4 $attribute->{associated_methods}++;
2504 return;
2505 }
2506 4 ▶ 
Subroutine install_accessors: called CC=7 SCAR=25.3
Pod undocumented
2507 4 sub install_accessors{
2508 my($attribute) = @_;
2509 4  
2510 4 my $metaclass = $attribute->associated_class;
2511 my $accessor_class = $attribute->accessor_metaclass;
2512 4  
2513 20 ▶ foreach my $type(qw(accessor reader writer predicate clearer)){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $attribute->{$type}) 4 16 20
2514 4 if(exists $attribute->{$type}){
2515 4 my $generator = '_generate_' . $type;
2516 4 my $code = $accessor_class->$generator($attribute, $metaclass);
2517 my $name = $attribute->{$type};
2518 # TODO: do something for compatibility
2519 # if( $metaclass->name->can($name) ) {
2520 # my $t = $metaclass->has_method($name) ? 'method' : 'function';
2521 # Carp::cluck("You are overwriting a locally defined $t"
2522 # . " ($name) with an accessor");
2523 4 # }
2524 4 $metaclass->add_method($name => $code);
2525 $attribute->associate_method($name);
2526 }
2527 }
2528  
2529 4 ▶ # install delegation
Branch: 1 branch
BranchTrueFalseTotal
if (exists $attribute->{"handles"}) 0 4 4
2530 0 if(exists $attribute->{handles}){
2531 0 ▶ my %handles = $attribute->_canonicalize_handles();
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %handles) 0 0 0
2532 0 ▶ while(my($handle, $method_to_call) = each %handles){
Branch: 1 branch
BranchTrueFalseTotal
if "Mouse::Object"->can($handle) 0 0 0
2533 next if Mouse::Object->can($handle);
2534 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($metaclass->has_method($handle)) 0 0 0
2535 0 if($metaclass->has_method($handle)) {
2536 $attribute->throw_error("You cannot overwrite a locally defined method ($handle) with a delegation");
2537 }
2538 0  
2539 $metaclass->add_method($handle =>
2540 $attribute->_make_delegation_method(
2541 $handle, $method_to_call));
2542 0  
2543 $attribute->associate_method($handle);
2544 }
2545 }
2546 4  
2547 return;
2548 }
2549  
2550 sub delegation_metaclass() { ## no critic
2551 'Mouse::Meta::Method::Delegation'
2552 }
2553 0 ▶ 
Subroutine _canonicalize_handles: not called CC=6 SCAR=37.4
2554 0 sub _canonicalize_handles {
2555 0 my($self) = @_;
2556 my $handles = $self->{handles};
2557 0  
2558 0 ▶ my $handle_type = ref $handles;
Branch: 4 branches
BranchTrueFalseTotal
if ($handle_type eq 'HASH') { } 0 0 0
elsif ($handle_type eq 'ARRAY') { } 0 0 0
elsif ($handle_type eq 'Regexp') { } 0 0 0
elsif ($handle_type eq 'CODE') { } 0 0 0
2559 0 if ($handle_type eq 'HASH') {
2560 return %$handles;
2561 }
2562 0 elsif ($handle_type eq 'ARRAY') {
2563 return map { $_ => $_ } @$handles;
2564 }
2565 0 elsif ($handle_type eq 'Regexp') {
2566 0 my $meta = $self->_find_delegate_metaclass();
2567 0 ▶ return map { $_ => $_ }
Branch: 1 branch
BranchTrueFalseTotal
Mouse::Util::is_a_metarole($meta) ? : 0 0 0
2568 grep { /$handles/ }
2569 Mouse::Util::is_a_metarole($meta)
2570 ? $meta->get_method_list
2571 : $meta->get_all_method_names;
2572 }
2573 0 elsif ($handle_type eq 'CODE') {
2574 return $handles->( $self, $self->_find_delegate_metaclass() );
2575 }
2576 0 else {
2577 $self->throw_error("Unable to canonicalize the 'handles' option with $handles");
2578 }
2579 }
2580 0 ▶ 
Subroutine _find_delegate_metaclass: not called CC=4 SCAR=30.0
2581 0 sub _find_delegate_metaclass {
2582 0 my($self) = @_;
2583 0 ▶ my $meta;
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'isa'}) { } 0 0 0
elsif ($self->{'does'}) { } 0 0 0
2584 0 if($self->{isa}) {
2585 $meta = Mouse::Meta::Class->initialize("$self->{isa}");
2586 }
2587 0 elsif($self->{does}) {
2588 $meta = Mouse::Util::get_metaclass_by_name("$self->{does}");
2589 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
defined $meta or $self->throw_error('Cannot find delegate metaclass for attribute ' . $self->name) 0 0 0
2590 defined($meta) or $self->throw_error(
2591 0 "Cannot find delegate metaclass for attribute " . $self->name);
2592 return $meta;
2593 }
2594  
2595 0 ▶ 
Subroutine _make_delegation_method: not called CC=1 SCAR=6.9
2596 0 sub _make_delegation_method {
2597 0 my($self, $handle, $method_to_call) = @_;
2598 return Mouse::Util::load_class($self->delegation_metaclass)
2599 ->_generate_delegation($self, $handle, $method_to_call);
2600 }
2601  
2602 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.8
2603 BEGIN{ # lib/Mouse/Meta/Class.pm
2604 2 ▶package Mouse::Meta::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
2605 use Mouse::Util qw/:meta/; # enables strict and warnings
2606 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
2607 use Scalar::Util ();
2608 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
2609 2 use Mouse::Meta::Module;
2610 our @ISA = qw(Mouse::Meta::Module);
2611 2  
2612 our @CARP_NOT = qw(Mouse); # trust Mouse
2613  
2614 sub attribute_metaclass;
2615 sub method_metaclass;
2616  
2617 sub constructor_class;
2618 sub destructor_class;
2619  
2620 4 ▶ 
Subroutine _construct_meta: called CC=3 SCAR=11.3
2621 4 sub _construct_meta {
2622 my($class, %args) = @_;
2623 4  
2624 4 $args{attributes} = {};
2625 4 $args{methods} = {};
2626 $args{roles} = [];
2627 4  
2628 2 ▶ $args{superclasses} = do {
Subroutine BEGIN: called CC=1 SCAR=0.0
2629 4 no strict 'refs';
2630 \@{ $args{package} . '::ISA' };
2631 };
2632 4 ▶ 
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
040
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
2633 4 ▶ my $self = bless \%args, ref($class) || $class;
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self ne __PACKAGE__) 0 4 4
2634 0 if(ref($self) ne __PACKAGE__){
2635 $self->meta->_initialize_object($self, \%args);
2636 4 }
2637 return $self;
2638 }
2639 0 ▶ 
Subroutine create_anon_class: not called CC=1 SCAR=6.9
Pod undocumented
2640 0 sub create_anon_class{
2641 0 my $self = shift;
2642 return $self->create(undef, @_);
2643 }
2644  
2645 sub is_anon_class;
2646  
2647 sub roles;
2648 0 ▶ 
Subroutine calculate_all_roles: not called CC=1 SCAR=6.9
Pod undocumented
2649 0 sub calculate_all_roles {
2650 0 my $self = shift;
2651 0 my %seen;
2652 0 return grep { !$seen{ $_->name }++ }
2653 map { $_->calculate_all_roles } @{ $self->roles };
2654 }
2655 8 ▶ 
Subroutine superclasses: called CC=4 SCAR=14.0
Pod documented
2656 8 sub superclasses {
2657 my $self = shift;
2658 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 4 4 8
2659 4 if (@_) {
2660 4 foreach my $super(@_){
2661 4 Mouse::Util::load_class($super);
2662 4 ▶ my $meta = Mouse::Util::get_metaclass_by_name($super);
Branch: 1 branch
BranchTrueFalseTotal
if $self->verify_superclass($super, $meta) 4 0 4
2663 0 next if $self->verify_superclass($super, $meta);
2664 $self->_reconcile_with_superclass_meta($meta);
2665 4 }
2666 return @{ $self->{superclasses} } = @_;
2667 }
2668 4  
2669 return @{ $self->{superclasses} };
2670 }
2671 4 ▶ 
Subroutine verify_superclass: called CC=7 SCAR=30.7
Pod undocumented
2672 4 sub verify_superclass {
2673 my($self, $super, $super_meta) = @_;
2674 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $super_meta) { } 0 4 4
2675 0 ▶ if(defined $super_meta) {
Branch: 1 branch
BranchTrueFalseTotal
if (Mouse::Util::is_a_metarole($super_meta)) 0 0 0
2676 0 if(Mouse::Util::is_a_metarole($super_meta)){
2677 $self->throw_error("You cannot inherit from a Mouse Role ($super)");
2678 }
2679 }
2680 else {
2681 # The metaclass of $super is not initialized.
2682 # i.e. it might be Mouse::Object, a mixin package (e.g. Exporter),
2683 # or a foreign class including Moose classes.
2684 4 # See also Mouse::Foreign::Meta::Role::Class.
2685 4 ▶ my $mm = $super->can('meta');
Branch: 1 branch
BranchTrueFalseTotal
unless ($mm and $mm == \&Mouse::Util::meta) 0 4 4
Condition33%1/3
$mm and $mm == \&Mouse::Util::meta
!ll&&!rl&&r
004
MC/DC0%0/2
$mm and $mm == \&Mouse::Util::meta
$mm $mm == \&Mouse::Util::meta
Truth table33%1/3
A and B
A= $mmB= $mm == \&Mouse::Util::meta
ABresult
0X0
100
111
2686 0 ▶ if(!($mm && $mm == \&Mouse::Util::meta)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($super->can("new") or $super->can("DESTROY")) 0 0 0
Condition0%0/3
$super->can("new") or $super->can("DESTROY")
l!l&&r!l&&!r
000
MC/DC0%0/2
$super->can("new") or $super->can("DESTROY")
$super->can("new") $super->can("DESTROY")
Truth table0%0/3
A or B
A= $super->can("new")B= $super->can("DESTROY")
ABresult
1X1
011
000
2687 0 if($super->can('new') or $super->can('DESTROY')) {
2688 $self->inherit_from_foreign_class($super);
2689 }
2690 4 }
2691 return 1; # always ok
2692 }
2693 0  
2694 return $self->isa(ref $super_meta); # checks metaclass compatibility
2695 }
2696 0 ▶ 
Subroutine inherit_from_foreign_class: not called CC=2 SCAR=17.9
Pod undocumented
2697 0 sub inherit_from_foreign_class {
2698 0 ▶ my($class, $super) = @_;
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"PERL_MOUSE_STRICT"}) 0 0 0
2699 0 if($ENV{PERL_MOUSE_STRICT}) {
2700 Carp::carp("You inherit from non-Mouse class ($super),"
2701 . " but it is unlikely to work correctly."
2702 . " Please consider using MouseX::Foreign");
2703 0 }
2704 return;
2705 }
2706 2  
2707 my @MetaClassTypes = (
2708 'attribute', # Mouse::Meta::Attribute
2709 'method', # Mouse::Meta::Method
2710 'constructor', # Mouse::Meta::Method::Constructor
2711 'destructor', # Mouse::Meta::Method::Destructor
2712 );
2713 0 ▶ 
Subroutine _reconcile_with_superclass_meta: not called CC=4 SCAR=30.0
2714 0 sub _reconcile_with_superclass_meta {
2715 my($self, $other) = @_;
2716  
2717 0 # find incompatible traits
2718 0 my %metaroles;
2719 0 ▶ foreach my $metaclass_type(@MetaClassTypes){
Condition0%0/3
$self->can($metaclass_type . '_metaclass') || $self->can($metaclass_type . '_class')
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->can($metaclass_type . '_metaclass') || $self->can($metaclass_type . '_class')
$self->can($metaclass_type . '_metaclass') $self->can($metaclass_type . '_class')
Truth table0%0/3
A || B
A= $self->can($metaclass_type . '_metaclass')B= $self->can($metaclass_type . '_class')
ABresult
1X1
011
000
2720 my $accessor = $self->can($metaclass_type . '_metaclass')
2721 || $self->can($metaclass_type . '_class');
2722 0  
2723 0 my $other_c = $other->$accessor();
2724 my $self_c = $self->$accessor();
2725 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless ($self_c->isa($other_c)) 0 0 0
2726 0 if(!$self_c->isa($other_c)){
2727 $metaroles{$metaclass_type}
2728 = [ $self_c->meta->_collect_roles($other_c->meta) ];
2729 }
2730 }
2731 0  
2732 $metaroles{class} = [$self->meta->_collect_roles($other->meta)];
2733  
2734 #use Data::Dumper; print Data::Dumper->new([\%metaroles], ['*metaroles'])->Indent(1)->Dump;
2735 0  
2736 0 require Mouse::Util::MetaRole;
2737 $_[0] = Mouse::Util::MetaRole::apply_metaroles(
2738 for => $self,
2739 class_metaroles => \%metaroles,
2740 0 );
2741 return;
2742 }
2743 0 ▶ 
Subroutine _collect_roles: not called CC=5 SCAR=34.0
2744 0 sub _collect_roles {
2745 my ($self, $other) = @_;
2746  
2747 0 # find common ancestor
2748 0 my @self_lin_isa = $self->linearized_isa;
2749 my @other_lin_isa = $other->linearized_isa;
2750 0  
2751 0 ▶ my(@self_anon_supers, @other_anon_supers);
Branch: 1 branch
BranchTrueFalseTotal
$self_lin_isa[0]->meta->is_anon_class and do { push @self_anon_supers, shift @self_lin_isa } 0 0 0
2752 0 ▶ push @self_anon_supers, shift @self_lin_isa while $self_lin_isa[0]->meta->is_anon_class;
Branch: 1 branch
BranchTrueFalseTotal
$other_lin_isa[0]->meta->is_anon_class and do { push @other_anon_supers, shift @other_lin_isa } 0 0 0
2753 push @other_anon_supers, shift @other_lin_isa while $other_lin_isa[0]->meta->is_anon_class;
2754 0 ▶ 
Condition0%0/3
$self_lin_isa[0] eq $other_lin_isa[0] && $self_lin_isa[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$self_lin_isa[0] eq $other_lin_isa[0] && $self_lin_isa[0]
$self_lin_isa[0] eq $other_lin_isa[0] $self_lin_isa[0]
Truth table0%0/3
A && B
A= $self_lin_isa[0] eq $other_lin_isa[0]B= $self_lin_isa[0]
ABresult
0X0
100
111
2755 my $common_ancestor = $self_lin_isa[0] eq $other_lin_isa[0] && $self_lin_isa[0];
2756 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless ($common_ancestor) 0 0 0
2757 0 if(!$common_ancestor){
2758 $self->throw_error(sprintf '%s cannot have %s as a super class because of their metaclass incompatibility',
2759 $self->name, $other->name);
2760 }
2761 0  
2762 0 my %seen;
2763 0 return sort grep { !$seen{$_}++ } ## no critic
2764 0 (map{ $_->name } map{ $_->meta->calculate_all_roles } @self_anon_supers),
2765 (map{ $_->name } map{ $_->meta->calculate_all_roles } @other_anon_supers),
2766 ;
2767 }
2768  
2769 0 ▶ 
Subroutine find_method_by_name: not called CC=4 SCAR=30.0
Pod undocumented
2770 0 sub find_method_by_name {
2771 0 ▶ my($self, $method_name) = @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $method_name or $self->throw_error("You must define a method name to find") 0 0 0
2772 defined($method_name)
2773 or $self->throw_error('You must define a method name to find');
2774 0  
2775 0 foreach my $class( $self->linearized_isa ){
2776 0 ▶ my $method = $self->initialize($class)->get_method($method_name);
Branch: 1 branch
BranchTrueFalseTotal
if defined $method 0 0 0
2777 return $method if defined $method;
2778 0 }
2779 return undef;
2780 }
2781 0 ▶ 
Subroutine get_all_methods: not called CC=1 SCAR=6.9
Pod documented
2782 0 sub get_all_methods {
2783 0 my($self) = @_;
2784 return map{ $self->find_method_by_name($_) } $self->get_all_method_names;
2785 }
2786 0 ▶ 
Subroutine get_all_method_names: not called CC=1 SCAR=6.9
Pod undocumented
2787 0 sub get_all_method_names {
2788 0 my $self = shift;
2789 0 my %uniq;
2790 0 return grep { $uniq{$_}++ == 0 }
2791 map { Mouse::Meta::Class->initialize($_)->get_method_list() }
2792 $self->linearized_isa;
2793 }
2794 0 ▶ 
Subroutine find_attribute_by_name: not called CC=4 SCAR=30.0
Pod undocumented
2795 0 sub find_attribute_by_name {
2796 0 ▶ my($self, $name) = @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $name or $self->throw_error("You must define an attribute name to find") 0 0 0
2797 defined($name)
2798 0 or $self->throw_error('You must define an attribute name to find');
2799 0 ▶ foreach my $attr($self->get_all_attributes) {
Branch: 1 branch
BranchTrueFalseTotal
if $attr->name eq $name 0 0 0
2800 return $attr if $attr->name eq $name;
2801 0 }
2802 return undef;
2803 }
2804 4 ▶ 
Subroutine add_attribute: called CC=13 SCAR=36.7
Pod documented
2805 4 sub add_attribute {
2806 my $self = shift;
2807 4  
2808 my($attr, $name);
2809 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($_[0])) { } 0 4 4
2810 0 if(Scalar::Util::blessed($_[0])){
2811 $attr = $_[0];
2812 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
$attr->isa("Mouse::Meta::Attribute") or $self->throw_error("Your attribute must be an instance of Mouse::Meta::Attribute (or a subclass)") 0 0 0
2813 $attr->isa('Mouse::Meta::Attribute')
2814 || $self->throw_error("Your attribute must be an instance of Mouse::Meta::Attribute (or a subclass)");
2815 0  
2816 $name = $attr->name;
2817 }
2818 else{
2819 4 # _process_attribute
2820 $name = shift;
2821 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 4 4
2822 my %args = (@_ == 1) ? %{$_[0]} : @_;
2823 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
defined $name or $self->throw_error("You must provide a name for the attribute") 4 0 4
2824 defined($name)
2825 or $self->throw_error('You must provide a name for the attribute');
2826 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s/^\+//) { } 0 4 4
2827 if ($name =~ s/^\+//) { # inherited attributes
2828 # Workaround for https://github.com/gfx/p5-Mouse/issues/64
2829 # Do not use find_attribute_by_name to avoid problems with cached attributes list
2830 0 # because we're about to change it anyway
2831 0 my $inherited_attr;
2832 0 ▶ foreach my $i ( @{ $self->_calculate_all_attributes } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i->name eq $name) 0 0 0
2833 0 if ( $i->name eq $name ) {
2834 0 $inherited_attr = $i;
2835 last;
2836 }
2837 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
unless $inherited_attr 0 0 0
2838 $self->throw_error("Could not find an attribute by the name of '$name' to inherit from in ".$self->name)
2839 unless $inherited_attr;
2840 0  
2841 $attr = $inherited_attr->clone_and_inherit_options(%args);
2842 }
2843 4 else{
2844 4 ▶ my($attribute_class, @traits) = $self->attribute_metaclass->interpolate_class(\%args);
Branch: 1 branch
BranchTrueFalseTotal
if @traits 0 4 4
2845 $args{traits} = \@traits if @traits;
2846 4  
2847 $attr = $attribute_class->new($name, %args);
2848 }
2849 }
2850 4  
2851 Scalar::Util::weaken( $attr->{associated_class} = $self );
2852  
2853 4 # install accessors first
2854 $attr->install_accessors();
2855  
2856 4 # then register the attribute to the metaclass
2857 4 $attr->{insertion_order} = keys %{ $self->{attributes} };
2858 4 $self->{attributes}{$name} = $attr;
2859 $self->_invalidate_metaclass_cache();
2860 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (not $attr->{"associated_methods"} and ($attr->{"is"} || "") ne "bare") 0 4 4
Condition20%1/5
not $attr->{"associated_methods"} and ($attr->{"is"} || "") ne "bare"
!ll&&!rl&&r
400
$attr->{'is'} || ''
l!l
00
MC/DC0%0/2
not $attr->{"associated_methods"} and ($attr->{"is"} || "") ne "bare"
not $attr->{"associated_methods"} $attr->{'is'}
Truth table33%1/3
not(A) and B
A= not $attr->{"associated_methods"}B= $attr->{'is'}
ABresult
0X0
100
111
2861 0 if(!$attr->{associated_methods} && ($attr->{is} || '') ne 'bare'){
2862 Carp::carp(qq{Attribute ($name) of class }.$self->name
2863 .qq{ has no associated methods (did you mean to provide an "is" argument?)});
2864 4 }
2865 return $attr;
2866 }
2867 4 ▶ 
Subroutine _calculate_all_attributes: called CC=3 SCAR=11.0
2868 4 sub _calculate_all_attributes {
2869 4 my($self) = @_;
2870 my %seen;
2871 4 my @all_attrs;
2872 8 ▶ foreach my $class($self->linearized_isa) {
Branch: 1 branch
BranchTrueFalseTotal
my $meta = Mouse::Util::get_metaclass_by_name($class) or next 4 4 8
2873 4 my $meta = Mouse::Util::get_metaclass_by_name($class) or next;
2874 my @attrs = grep { !$seen{$_->name}++ } values %{$meta->{attributes}};
2875 4 @attrs = sort {
2876 0 $b->{insertion_order} <=> $a->{insertion_order}
2877 4 } @attrs;
2878 push @all_attrs, @attrs;
2879 4 }
2880 return [reverse @all_attrs];
2881 }
2882  
2883 sub linearized_isa;
2884  
2885 sub new_object;
2886 sub clone_object;
2887 0 ▶ 
Subroutine immutable_options: not called CC=1 SCAR=6.9
Pod undocumented
2888 0 sub immutable_options {
2889 my ( $self, @args ) = @_;
2890  
2891 0 return (
2892 inline_constructor => 1,
2893 inline_destructor => 1,
2894 constructor_name => 'new',
2895 @args,
2896 );
2897 }
2898 0 ▶ 
Subroutine make_immutable: not called CC=3 SCAR=24.8
Pod undocumented
2899 0 sub make_immutable {
2900 0 my $self = shift;
2901 my %args = $self->immutable_options(@_);
2902 0  
2903 $self->{is_immutable}++;
2904 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"inline_constructor"}) 0 0 0
2905 if ($args{inline_constructor}) {
2906 0 $self->add_method($args{constructor_name} =>
2907 Mouse::Util::load_class($self->constructor_class)
2908 ->_generate_constructor($self, \%args));
2909 }
2910 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"inline_destructor"}) 0 0 0
2911 0 if ($args{inline_destructor}) {
2912 $self->add_method(DESTROY =>
2913 Mouse::Util::load_class($self->destructor_class)
2914 ->_generate_destructor($self, \%args));
2915 }
2916  
2917 # Moose's make_immutable returns true allowing calling code to skip
2918 0 # setting an explicit true value at the end of a source file.
2919 return 1;
2920 }
2921 0 ▶ 
Subroutine make_mutable: not called CC=1 SCAR=6.9
Pod undocumented
2922 0 sub make_mutable {
2923 0 my($self) = @_;
2924 0 $self->{is_immutable} = 0;
2925 return;
2926 }
2927  
2928 0 ▶sub is_immutable;
Subroutine is_mutable: not called CC=1 SCAR=6.9
Pod undocumented
2929 sub is_mutable { !$_[0]->is_immutable }
2930 0 ▶ 
Subroutine _install_modifier: not called CC=5 SCAR=34.0
2931 0 sub _install_modifier {
2932 0 my( $self, $type, $name, $code ) = @_;
2933 my $into = $self->name;
2934 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $original = $into->can($name) or $self->throw_error("The method '${name}' was not found in the inheritance hierarchy for $into") 0 0 0
2935 my $original = $into->can($name)
2936 or $self->throw_error("The method '$name' was not found in the inheritance hierarchy for $into");
2937 0  
2938 my $modifier_table = $self->{modifiers}{$name};
2939 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless ($modifier_table) 0 0 0
2940 0 if(!$modifier_table){
2941 0 my(@before, @after, @around);
2942 0 ▶ my $cache = $original;
Subroutine __ANON__: not called CC=9 SCAR=45.0
2943 0 ▶ my $modified = sub {
Branch: 1 branch
BranchTrueFalseTotal
if (@before) 0 0 0
2944 0 if(@before) {
2945 for my $c (@before) { $c->(@_) }
2946 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
unless (@after) 0 0 0
2947 0 unless(@after) {
2948 return $cache->(@_);
2949 }
2950 0 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
elsif (defined wantarray) { } 0 0 0
2951 0 if(wantarray){ # list context
2952 my @rval = $cache->(@_);
2953 0  
2954 0 for my $c(@after){ $c->(@_) }
2955 return @rval;
2956 }
2957 0 elsif(defined wantarray){ # scalar context
2958 my $rval = $cache->(@_);
2959 0  
2960 0 for my $c(@after){ $c->(@_) }
2961 return $rval;
2962 }
2963 0 else{ # void context
2964 $cache->(@_);
2965 0  
2966 0 for my $c(@after){ $c->(@_) }
2967 return;
2968 0 }
2969 };
2970 0  
2971 $self->{modifiers}{$name} = $modifier_table = {
2972 original => $original,
2973  
2974 before => \@before,
2975 after => \@after,
2976 around => \@around,
2977  
2978 cache => \$cache, # cache for around modifiers
2979 };
2980 0  
2981 $self->add_method($name => $modified);
2982 }
2983 0 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'before') { } 0 0 0
elsif ($type eq 'after') { } 0 0 0
2984 0 if($type eq 'before'){
2985 unshift @{$modifier_table->{before}}, $code;
2986 }
2987 0 elsif($type eq 'after'){
2988 push @{$modifier_table->{after}}, $code;
2989 }
2990 0 else{ # around
2991 push @{$modifier_table->{around}}, $code;
2992 0  
2993 0 ▶ my $next = ${ $modifier_table->{cache} };
Subroutine __ANON__: not called CC=1 SCAR=6.9
2994 ${ $modifier_table->{cache} } = sub{ $code->($next, @_) };
2995 }
2996 0  
2997 return;
2998 }
2999 0 ▶ 
Subroutine add_before_method_modifier: not called CC=1 SCAR=6.9
Pod undocumented
3000 0 sub add_before_method_modifier {
3001 0 my ( $self, $name, $code ) = @_;
3002 $self->_install_modifier( 'before', $name, $code );
3003 }
3004 0 ▶ 
Subroutine add_around_method_modifier: not called CC=1 SCAR=6.9
Pod undocumented
3005 0 sub add_around_method_modifier {
3006 0 my ( $self, $name, $code ) = @_;
3007 $self->_install_modifier( 'around', $name, $code );
3008 }
3009 0 ▶ 
Subroutine add_after_method_modifier: not called CC=1 SCAR=6.9
Pod undocumented
3010 0 sub add_after_method_modifier {
3011 0 my ( $self, $name, $code ) = @_;
3012 $self->_install_modifier( 'after', $name, $code );
3013 }
3014 0 ▶ 
Subroutine add_override_method_modifier: not called CC=3 SCAR=24.8
Pod undocumented
3015 0 sub add_override_method_modifier {
3016 my ($self, $name, $code) = @_;
3017 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_method($name)) 0 0 0
3018 0 if($self->has_method($name)){
3019 $self->throw_error("Cannot add an override method if a local method is already present");
3020 }
3021 0  
3022 my $package = $self->name;
3023 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $super_body = $package->can($name) or $self->throw_error("You cannot override '${name}' because it has no super method") 0 0 0
3024 my $super_body = $package->can($name)
3025 or $self->throw_error("You cannot override '$name' because it has no super method");
3026 0 ▶ 
Subroutine __ANON__: not called CC=1 SCAR=6.9
3027 0 $self->add_method($name => sub {
3028 0 local $Mouse::SUPER_PACKAGE = $package;
3029 0 local $Mouse::SUPER_BODY = $super_body;
3030 0 local @Mouse::SUPER_ARGS = @_;
3031 0 &{$code};
3032 0 });
3033 return;
3034 }
3035 0 ▶ 
Subroutine add_augment_method_modifier: not called CC=3 SCAR=24.8
Pod undocumented
3036 0 sub add_augment_method_modifier {
3037 0 ▶ my ($self, $name, $code) = @_;
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_method($name)) 0 0 0
3038 0 if($self->has_method($name)){
3039 $self->throw_error("Cannot add an augment method if a local method is already present");
3040 }
3041 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $super = $self->find_method_by_name($name) or $self->throw_error("You cannot augment '${name}' because it has no super method") 0 0 0
3042 my $super = $self->find_method_by_name($name)
3043 or $self->throw_error("You cannot augment '$name' because it has no super method");
3044 0  
3045 0 my $super_package = $super->package_name;
3046 my $super_body = $super->body;
3047 0 ▶ 
Subroutine __ANON__: not called CC=1 SCAR=6.9
3048 0 $self->add_method($name => sub {
3049 0 local $Mouse::INNER_BODY{$super_package} = $code;
3050 0 local $Mouse::INNER_ARGS{$super_package} = [@_];
3051 0 &{$super_body};
3052 0 });
3053 return;
3054 }
3055 0 ▶ 
Subroutine does_role: not called CC=7 SCAR=40.3
Pod undocumented
3056 0 sub does_role {
3057 my ($self, $role_name) = @_;
3058 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
defined $role_name or $self->throw_error("You must supply a role name to look for") 0 0 0
3059 (defined $role_name)
3060 || $self->throw_error("You must supply a role name to look for");
3061 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ref $role_name 0 0 0
3062 $role_name = $role_name->name if ref $role_name;
3063 0  
3064 0 ▶ for my $class ($self->linearized_isa) {
Branch: 1 branch
BranchTrueFalseTotal
my $meta = Mouse::Util::get_metaclass_by_name($class) or next 0 0 0
3065 my $meta = Mouse::Util::get_metaclass_by_name($class)
3066 or next;
3067 0  
3068 for my $role (@{ $meta->roles }) {
3069 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $role->does_role($role_name) 0 0 0
3070 return 1 if $role->does_role($role_name);
3071 }
3072 }
3073 0  
3074 return 0;
3075 }
3076  
3077 }
3078 BEGIN{ # lib/Mouse/Meta/Method.pm
3079 2 ▶package Mouse::Meta::Method;
Subroutine BEGIN: called CC=1 SCAR=0.0
3080 2 ▶use Mouse::Util qw(:meta); # enables strict and warnings
Subroutine BEGIN: called CC=1 SCAR=0.0
3081 use Scalar::Util ();
3082  
3083 2 ▶use overload
Subroutine BEGIN: called CC=1 SCAR=0.2
3084 '==' => '_equal',
3085 0 ▶ 'eq' => '_equal',
Subroutine __ANON__: not called CC=1 SCAR=6.9
3086 2 ▶ '&{}' => sub{ $_[0]->body },
Subroutine BEGIN: not called CC=1 SCAR=0.0
3087 2 fallback => 1,
3088 ;
3089 0 ▶ 
Subroutine wrap: not called CC=2 SCAR=17.9
Pod undocumented
3090 0 sub wrap {
3091 0 ▶ my $class = shift;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 != 0 0 0 0
3092 0 unshift @_, 'body' if @_ % 2 != 0;
3093 return $class->_new(@_);
3094 }
3095 0 ▶ 
Subroutine _new: not called CC=2 SCAR=17.9
3096 0 sub _new{
3097 0 my($class, %args) = @_;
3098 my $self = bless \%args, $class;
3099 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($class ne __PACKAGE__) 0 0 0
3100 0 if($class ne __PACKAGE__){
3101 $self->meta->_initialize_object($self, \%args);
3102 0 }
3103 return $self;
3104 }
3105 0 ▶ 
Subroutine body: not called CC=1 SCAR=6.9
Pod undocumented
3106 0 ▶sub body { $_[0]->{body} }
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
3107 0 ▶sub name { $_[0]->{name} }
Subroutine package_name: not called CC=1 SCAR=6.9
Pod undocumented
3108 0 ▶sub package_name { $_[0]->{package} }
Subroutine associated_metaclass: not called CC=1 SCAR=6.9
Pod undocumented
3109 sub associated_metaclass { $_[0]->{associated_metaclass} }
3110 0 ▶ 
Subroutine fully_qualified_name: not called CC=1 SCAR=6.9
Pod undocumented
3111 0 sub fully_qualified_name {
3112 0 my($self) = @_;
3113 return $self->package_name . '::' . $self->name;
3114 }
3115  
3116 0 ▶# for Moose compat
Subroutine _equal: not called CC=4 SCAR=30.0
3117 0 sub _equal {
3118 my($l, $r) = @_;
3119 0 ▶ 
Condition0%0/9
builtin::blessed($r) && $l->body == $r->body && $l->name eq $r->name && $l->package_name eq $r->package_name
!ll&&!rl&&r
000
builtin::blessed($r) and $l->body == $r->body and $l->name eq $r->name
!ll&&!rl&&r
000
builtin::blessed($r) and $l->body == $r->body
!ll&&!rl&&r
000
MC/DC0%0/4
builtin::blessed($r) && $l->body == $r->body && $l->name eq $r->name && $l->package_name eq $r->package_name
builtin::blessed($r) $l->body == $r->body $l->name eq $r->name $l->package_name eq $r->package_name
Truth table0%0/5
A and B and C && D
A= builtin::blessed($r)B= $l->body == $r->bodyC= $l->name eq $r->nameD= $l->package_name eq $r->package_name
ABCDresult
0XXX0
10XX0
110X0
11100
11111
3120 return Scalar::Util::blessed($r)
3121 && $l->body == $r->body
3122 && $l->name eq $r->name
3123 && $l->package_name eq $r->package_name;
3124 }
3125  
3126 }
3127 BEGIN{ # lib/Mouse/Meta/Method/Accessor.pm
3128 2 ▶package Mouse::Meta::Method::Accessor;
Subroutine BEGIN: called CC=1 SCAR=0.0
3129 use Mouse::Util qw(:meta); # enables strict and warnings
3130 2 ▶ 
Subroutine BEGIN: called CC=2 SCAR=7.1
Subroutine BEGIN: not called CC=1 SCAR=0.1
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'MOUSE_DEBUG'} ? : 0 2 2
3131 use constant _MOUSE_DEBUG => $ENV{MOUSE_DEBUG} ? 1 : 0;
3132 4 ▶ 
Subroutine _inline_slot: called CC=1 SCAR=0.0
3133 4 sub _inline_slot{
3134 4 my(undef, $self_var, $attr_name) = @_;
3135 return sprintf '%s->{q{%s}}', $self_var, $attr_name;
3136 }
3137 4 ▶ 
Subroutine _generate_accessor_any: called CC=28 SCAR=52.2
3138 4 sub _generate_accessor_any{
3139 my($method_class, $type, $attribute, $class) = @_;
3140 4  
3141 4 my $name = $attribute->name;
3142 4 my $default = $attribute->default;
3143 4 my $constraint = $attribute->type_constraint;
3144 4 my $builder = $attribute->builder;
3145 4 my $trigger = $attribute->trigger;
3146 4 my $is_weak = $attribute->is_weak_ref;
3147 4 ▶ my $should_deref = $attribute->should_auto_deref;
Condition33%2/6
defined $constraint && $constraint->has_coercion && $attribute->should_coerce
!ll&&!rl&&r
400
defined $constraint and $constraint->has_coercion
!ll&&!rl&&r
400
MC/DC0%0/3
defined $constraint && $constraint->has_coercion && $attribute->should_coerce
defined $constraint $constraint->has_coercion $attribute->should_coerce
Truth table25%1/4
A and B && C
A= defined $constraintB= $constraint->has_coercionC= $attribute->should_coerce
ABCresult
0XX0
10X0
1100
1111
3148 my $should_coerce = (defined($constraint)
3149 && $constraint->has_coercion
3150 && $attribute->should_coerce);
3151 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
defined $constraint ? : 0 4 4
3152 my $compiled_type_constraint = defined($constraint)
3153 ? $constraint->_compiled_type_constraint
3154 : undef;
3155 4  
3156 4 my $self = '$_[0]';
3157 my $slot = $method_class->_inline_slot($self, $name);;
3158 4  
3159 my $accessor = sprintf(qq{package %s;\n#line 1 "%s-accessor for %s (%s)"\n}, $class->name, $type, $name, __FILE__)
3160 . "sub {\n";
3161 4 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'rw' or $type eq 'wo') { } 4 0 4
elsif ($type eq 'ro') { } 0 0 0
Condition33%1/3
$type eq "rw" or $type eq "wo"
l!l&&r!l&&!r
400
MC/DC0%0/2
$type eq "rw" or $type eq "wo"
$type eq "rw" $type eq "wo"
Truth table33%1/3
A or B
A= $type eq "rw"B= $type eq "wo"
ABresult
1X1
011
000
3162 4 ▶ if ($type eq 'rw' || $type eq 'wo') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'rw') { } 4 0 4
3163 4 if($type eq 'rw'){
3164 $accessor .=
3165 'if (scalar(@_) >= 2) {' . "\n";
3166 }
3167 0 else{ # writer
3168 $accessor .=
3169 'if(@_ < 2){ Carp::confess("Not enough arguments for the writer of $name") }'.
3170 '{' . "\n";
3171 }
3172 4  
3173 my $value = '$_[1]';
3174 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $constraint) 0 4 4
3175 0 ▶ if (defined $constraint) {
Branch: 1 branch
BranchTrueFalseTotal
if ($should_coerce) 0 0 0
3176 0 if ($should_coerce) {
3177 $accessor .=
3178 "\n".
3179 0 'my $val = $constraint->coerce('.$value.');';
3180 $value = '$val';
3181 }
3182 0 $accessor .=
3183 "\n".
3184 '$compiled_type_constraint->('.$value.') or
3185 $attribute->_throw_type_constraint_error('.$value.', $constraint);' . "\n";
3186 }
3187  
3188 # if there's nothing left to do for the attribute we can return during
3189 4 ▶ # this setter
Branch: 1 branch
BranchTrueFalseTotal
unless $is_weak or $trigger or $should_deref 4 0 4
Condition33%2/6
$is_weak or $trigger or $should_deref
l!l&&r!l&&!r
004
$is_weak or $trigger
l!l&&r!l&&!r
004
MC/DC0%0/3
$is_weak or $trigger or $should_deref
$is_weak $trigger $should_deref
Truth table25%1/4
A or B or C
A= $is_weakB= $triggerC= $should_deref
ABCresult
1XX1
01X1
0011
0000
3190 $accessor .= 'return ' if !$is_weak && !$trigger && !$should_deref;
3191 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $trigger 0 4 4
3192 4 $accessor .= "my \@old_value = exists $slot ? $slot : ();\n" if $trigger;
3193 $accessor .= "$slot = $value;\n";
3194 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($is_weak) 0 4 4
3195 0 if ($is_weak) {
3196 $accessor .= "Scalar::Util::weaken($slot) if ref $slot;\n";
3197 }
3198 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($trigger) 0 4 4
3199 0 if ($trigger) {
3200 $accessor .= '$trigger->('.$self.', '.$value.', @old_value);' . "\n";
3201 }
3202 4  
3203 $accessor .= "}\n";
3204 }
3205 0 elsif($type eq 'ro') {
3206 $accessor .= 'Carp::confess("Cannot assign a value to a read-only accessor of $name") if scalar(@_) >= 2;' . "\n";
3207 }
3208 0 else{
3209 $class->throw_error("Unknown accessor type '$type'");
3210 }
3211 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($attribute->is_lazy and $type ne "wo") 0 4 4
Condition33%1/3
$attribute->is_lazy and $type ne "wo"
!ll&&!rl&&r
400
MC/DC0%0/2
$attribute->is_lazy and $type ne "wo"
$attribute->is_lazy $type ne "wo"
Truth table33%1/3
A and B
A= $attribute->is_lazyB= $type ne "wo"
ABresult
0X0
100
111
3212 0 if ($attribute->is_lazy and $type ne 'wo') {
3213 my $value;
3214 0 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if (defined $builder) { } 0 0 0
elsif (ref $default eq 'CODE') { } 0 0 0
3215 0 if (defined $builder){
3216 $value = "$self->\$builder()";
3217 }
3218 0 elsif (ref($default) eq 'CODE'){
3219 $value = "$self->\$default()";
3220 }
3221 0 else{
3222 $value = '$default';
3223 }
3224 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "rw" 0 0 0
3225 0 $accessor .= "els" if $type eq 'rw';
3226 0 ▶ $accessor .= "if(!exists $slot){\n";
Branch: 2 branches
BranchTrueFalseTotal
if ($should_coerce) { } 0 0 0
elsif (defined $constraint) { } 0 0 0
3227 0 if($should_coerce){
3228 $accessor .= "$slot = \$constraint->coerce($value)";
3229 }
3230 0 elsif(defined $constraint){
3231 0 $accessor .= "my \$tmp = $value;\n";
3232 0 $accessor .= "\$compiled_type_constraint->(\$tmp)";
3233 0 $accessor .= " || \$attribute->_throw_type_constraint_error(\$tmp, \$constraint);\n";
3234 $accessor .= "$slot = \$tmp;\n";
3235 }
3236 0 else{
3237 $accessor .= "$slot = $value;\n";
3238 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
if ($is_weak) 0 0 0
3239 0 if ($is_weak) {
3240 $accessor .= "Scalar::Util::weaken($slot) if ref $slot;\n";
3241 0 }
3242 $accessor .= "}\n";
3243 }
3244 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($should_deref) 0 4 4
3245 0 ▶ if ($should_deref) {
Branch: 2 branches
BranchTrueFalseTotal
if ($constraint->is_a_type_of('ArrayRef')) { } 0 0 0
elsif ($constraint->is_a_type_of('HashRef')) { } 0 0 0
3246 0 if ($constraint->is_a_type_of('ArrayRef')) {
3247 $accessor .= "return \@{ $slot || [] } if wantarray;\n";
3248 }
3249 0 elsif($constraint->is_a_type_of('HashRef')){
3250 $accessor .= "return \%{ $slot || {} } if wantarray;\n";
3251 }
3252 0 else{
3253 $class->throw_error("Can not auto de-reference the type constraint " . $constraint->name);
3254 }
3255 }
3256 4  
3257 $accessor .= "return $slot;\n}\n";
3258 4  
3259 4 warn $accessor if _MOUSE_DEBUG;
3260 4 my $code;
3261 4 my $e = do{
3262 4 local $@;
3263 4 $code = eval $accessor;
3264 $@;
3265 4 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
if $e 0 4 4
3266 die $e if $e;
3267 4  
3268 return $code;
3269 }
3270 4 ▶ 
Subroutine _generate_accessor: called CC=1 SCAR=0.0
3271 sub _generate_accessor{
3272 4 #my($self, $attribute, $metaclass) = @_;
3273 4 my $self = shift;
3274 return $self->_generate_accessor_any(rw => @_);
3275 }
3276 0 ▶ 
Subroutine _generate_reader: not called CC=1 SCAR=6.9
3277 sub _generate_reader {
3278 0 #my($self, $attribute, $metaclass) = @_;
3279 0 my $self = shift;
3280 return $self->_generate_accessor_any(ro => @_);
3281 }
3282 0 ▶ 
Subroutine _generate_writer: not called CC=1 SCAR=6.9
3283 sub _generate_writer {
3284 0 #my($self, $attribute, $metaclass) = @_;
3285 0 my $self = shift;
3286 return $self->_generate_accessor_any(wo => @_);
3287 }
3288 0 ▶ 
Subroutine _generate_predicate: not called CC=1 SCAR=6.9
3289 sub _generate_predicate {
3290 0 #my($self, $attribute, $metaclass) = @_;
3291 my(undef, $attribute) = @_;
3292 0  
3293 0 ▶ my $slot = $attribute->name;
Subroutine __ANON__: not called CC=1 SCAR=6.9
3294 0 return sub{
3295 0 return exists $_[0]->{$slot};
3296 };
3297 }
3298 0 ▶ 
Subroutine _generate_clearer: not called CC=1 SCAR=6.9
3299 sub _generate_clearer {
3300 0 #my($self, $attribute, $metaclass) = @_;
3301 my(undef, $attribute) = @_;
3302 0  
3303 0 ▶ my $slot = $attribute->name;
Subroutine __ANON__: not called CC=1 SCAR=6.9
3304 0 return sub{
3305 0 delete $_[0]->{$slot};
3306 };
3307 }
3308  
3309 }
3310 BEGIN{ # lib/Mouse/Meta/Method/Constructor.pm
3311 2 ▶package Mouse::Meta::Method::Constructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
3312 use Mouse::Util qw(:meta); # enables strict and warnings
3313 2 ▶ 
Subroutine BEGIN: called CC=2 SCAR=7.1
Subroutine BEGIN: not called CC=1 SCAR=0.1
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'MOUSE_DEBUG'} ? : 0 2 2
3314 use constant _MOUSE_DEBUG => $ENV{MOUSE_DEBUG} ? 1 : 0;
3315 4 ▶ 
Subroutine _inline_slot: called CC=1 SCAR=0.0
3316 4 sub _inline_slot{
3317 4 my(undef, $self_var, $attr_name) = @_;
3318 return sprintf '%s->{q{%s}}', $self_var, $attr_name;
3319 }
3320 0 ▶ 
Subroutine _generate_constructor: not called CC=3 SCAR=24.8
3321 0 sub _generate_constructor {
3322 my ($class, $metaclass, $args) = @_;
3323 0  
3324 my $associated_metaclass_name = $metaclass->name;
3325 0  
3326 0 my $buildall = $class->_generate_BUILDALL($metaclass);
3327 my $buildargs = $class->_generate_BUILDARGS($metaclass);
3328 0 ▶ my $initializer = $metaclass->{_mouse_cache}{_initialize_object} ||=
Condition0%0/3
$metaclass->{"_mouse_cache"}{"_initialize_object"} ||= $class->_generate_initialize_object($metaclass)
l!l&&r!l&&!r
000
MC/DC0%0/2
$metaclass->{"_mouse_cache"}{"_initialize_object"} ||= $class->_generate_initialize_object($metaclass)
$metaclass->{"_mouse_cache"}{"_initialize_object"} $class->_generate_initialize_object($metaclass)
Truth table0%0/3
A ||= B
A= $metaclass->{"_mouse_cache"}{"_initialize_object"}B= $class->_generate_initialize_object($metaclass)
ABresult
1X1
011
000
3329 0 $class->_generate_initialize_object($metaclass);
3330 my $source = sprintf(<<'EOT', __FILE__, $metaclass->name, $buildargs, $buildall);
3331 #line 1 "%s"
3332 package %s;
3333 sub {
3334 my $class = shift;
3335 return $class->Mouse::Object::new(@_)
3336 if $class ne __PACKAGE__;
3337 # BUILDARGS
3338 %s;
3339 my $instance = bless {}, $class;
3340 $metaclass->$initializer($instance, $args, 0);
3341 # BUILDALL
3342 %s;
3343 return $instance;
3344 }
3345 0 EOT
3346 0 warn $source if _MOUSE_DEBUG;
3347 0 my $body;
3348 0 my $e = do{
3349 0 local $@;
3350 0 $body = eval $source;
3351 $@;
3352 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
if $e 0 0 0
3353 0 die $e if $e;
3354 return $body;
3355 }
3356 4 ▶ 
Subroutine _generate_initialize_object: called CC=25 SCAR=45.6
3357 4 sub _generate_initialize_object {
3358 4 my ($method_class, $metaclass) = @_;
3359 my @attrs = $metaclass->get_all_attributes;
3360 4 ▶ 
Condition33%1/3
$_ && $_->_compiled_type_constraint
!ll&&!rl&&r
400
MC/DC0%0/2
$_ && $_->_compiled_type_constraint
$_ $_->_compiled_type_constraint
Truth table33%1/3
A && B
A= $_B= $_->_compiled_type_constraint
ABresult
0X0
100
111
3361 4 my @checks = map { $_ && $_->_compiled_type_constraint }
3362 map { $_->type_constraint } @attrs;
3363 4  
3364 my @res;
3365  
3366 4 my $has_triggers;
3367 my $strict = $metaclass->strict_constructor;
3368 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($strict) 0 4 4
3369 0 if($strict){
3370 push @res, 'my $used = 0;';
3371 }
3372 4  
3373 4 for my $index (0 .. @attrs - 1) {
3374 my $code = '';
3375 4  
3376 4 my $attr = $attrs[$index];
3377 my $key = $attr->name;
3378 4  
3379 4 my $init_arg = $attr->init_arg;
3380 4 my $type_constraint = $attr->type_constraint;
3381 4 my $is_weak_ref = $attr->is_weak_ref;
3382 my $need_coercion;
3383 4  
3384 4 my $instance_slot = $method_class->_inline_slot('$instance', $key);
3385 4 my $attr_var = "\$attrs[$index]";
3386 my $constraint_var;
3387 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type_constraint) 0 4 4
3388 0 if(defined $type_constraint){
3389 0 ▶ $constraint_var = "$attr_var\->{type_constraint}";
Condition0%0/3
$attr->should_coerce && $type_constraint->has_coercion
!ll&&!rl&&r
000
MC/DC0%0/2
$attr->should_coerce && $type_constraint->has_coercion
$attr->should_coerce $type_constraint->has_coercion
Truth table0%0/3
A && B
A= $attr->should_coerceB= $type_constraint->has_coercion
ABresult
0X0
100
111
3390 $need_coercion = ($attr->should_coerce && $type_constraint->has_coercion);
3391 }
3392 4  
3393 $code .= "# initialize $key\n";
3394 4  
3395 4 ▶ my $post_process = '';
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type_constraint) 0 4 4
3396 0 if(defined $type_constraint){
3397 0 $post_process .= "\$checks[$index]->($instance_slot)\n";
3398 $post_process .= " or $attr_var->_throw_type_constraint_error($instance_slot, $constraint_var);\n";
3399 }
3400  
3401 4 ▶ # build cde for an attribute
Branch: 1 branch
BranchTrueFalseTotal
if (defined $init_arg) 4 0 4
3402 4 if (defined $init_arg) {
3403 my $value = "\$args->{q{$init_arg}}";
3404 4  
3405 $code .= "if (exists $value) {\n";
3406 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($need_coercion) 0 4 4
3407 0 if($need_coercion){
3408 $value = "$constraint_var->coerce($value)";
3409 }
3410 4  
3411 4 $code .= "$instance_slot = $value;\n";
3412 $code .= $post_process;
3413 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($attr->has_trigger) 0 4 4
3414 0 if ($attr->has_trigger) {
3415 0 $has_triggers++;
3416 $code .= "push \@triggers, [$attr_var\->{trigger}, $instance_slot];\n";
3417 }
3418 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($strict) 0 4 4
3419 0 if ($strict){
3420 $code .= '++$used;' . "\n";
3421 }
3422 4  
3423 $code .= "\n} else {\n"; # $value exists
3424 }
3425 4 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if ($attr->has_default or $attr->has_builder) { } 0 4 4
elsif ($attr->is_required) { } 0 4 4
Condition33%1/3
$attr->has_default or $attr->has_builder
l!l&&r!l&&!r
004
MC/DC0%0/2
$attr->has_default or $attr->has_builder
$attr->has_default $attr->has_builder
Truth table33%1/3
A or B
A= $attr->has_defaultB= $attr->has_builder
ABresult
1X1
011
000
3426 0 ▶ if ($attr->has_default || $attr->has_builder) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attr->is_lazy) 0 0 0
3427 0 unless ($attr->is_lazy) {
3428 0 my $default = $attr->default;
3429 my $builder = $attr->builder;
3430 0  
3431 0 ▶ my $value;
Branch: 3 branches
BranchTrueFalseTotal
if (defined $builder) { } 0 0 0
elsif (ref $default eq 'CODE') { } 0 0 0
elsif (defined $default) { } 0 0 0
3432 0 if (defined($builder)) {
3433 $value = "\$instance->$builder()";
3434 }
3435 0 elsif (ref($default) eq 'CODE') {
3436 $value = "$attr_var\->{default}->(\$instance)";
3437 }
3438 0 elsif (defined($default)) {
3439 $value = "$attr_var\->{default}";
3440 }
3441 0 else {
3442 $value = 'undef';
3443 }
3444 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($need_coercion) 0 0 0
3445 0 if($need_coercion){
3446 $value = "$constraint_var->coerce($value)";
3447 }
3448 0  
3449 0 $code .= "$instance_slot = $value;\n";
3450 $code .= $post_process;
3451 }
3452 }
3453 0 elsif ($attr->is_required) {
3454 0 $code .= "\$meta->throw_error('Attribute ($key) is required')";
3455 $code .= " unless \$is_cloning;\n";
3456 }
3457 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if defined $init_arg 4 0 4
3458 $code .= "}\n" if defined $init_arg;
3459 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($is_weak_ref) 0 4 4
3460 0 if($is_weak_ref){
3461 $code .= "Scalar::Util::weaken($instance_slot) "
3462 . "if ref $instance_slot and not Scalar::Util::isweak($instance_slot);\n";
3463 }
3464 4  
3465 push @res, $code;
3466 }
3467 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($strict) 0 4 4
3468 0 if($strict){
3469 push @res, q{if($used < keys %{$args})}
3470 . q{{ $meta->_report_unknown_args(\@attrs, $args) }};
3471 }
3472 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($metaclass->is_anon_class) 0 4 4
3473 0 if($metaclass->is_anon_class){
3474 push @res, q{$instance->{__METACLASS__} = $meta;};
3475 }
3476 4 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($has_triggers) 0 4 4
3477 0 if($has_triggers){
3478 0 unshift @res, q{my @triggers;};
3479 push @res, q{$_->[0]->($instance, $_->[1]) for @triggers;};
3480 }
3481 4  
3482 my $source = sprintf <<'EOT', __FILE__, $metaclass->name, join "\n", @res;
3483 #line 1 "%s"
3484 package %s;
3485 sub {
3486 my($meta, $instance, $args, $is_cloning) = @_;
3487 %s;
3488 return $instance;
3489 }
3490 4 EOT
3491 4 warn $source if _MOUSE_DEBUG;
3492 4 my $body;
3493 4 my $e = do {
3494 4 local $@;
3495 4 $body = eval $source;
3496 $@;
3497 4 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
if $e 0 4 4
3498 4 die $e if $e;
3499 return $body;
3500 }
3501 0 ▶ 
Subroutine _generate_BUILDARGS: not called CC=3 SCAR=24.8
3502 0 sub _generate_BUILDARGS {
3503 my(undef, $metaclass) = @_;
3504 0  
3505 0 ▶ my $class = $metaclass->name;
Branch: 1 branch
BranchTrueFalseTotal
if ($class->can("BUILDARGS") and $class->can("BUILDARGS") != \&Mouse::Object::BUILDARGS) 0 0 0
Condition0%0/3
$class->can("BUILDARGS") and $class->can("BUILDARGS") != \&Mouse::Object::BUILDARGS
!ll&&!rl&&r
000
MC/DC0%0/2
$class->can("BUILDARGS") and $class->can("BUILDARGS") != \&Mouse::Object::BUILDARGS
$class->can("BUILDARGS") $class->can("BUILDARGS") != \&Mouse::Object::BUILDARGS
Truth table0%0/3
A and B
A= $class->can("BUILDARGS")B= $class->can("BUILDARGS") != \&Mouse::Object::BUILDARGS
ABresult
0X0
100
111
3506 0 if ( $class->can('BUILDARGS') && $class->can('BUILDARGS') != \&Mouse::Object::BUILDARGS ) {
3507 return 'my $args = $class->BUILDARGS(@_)';
3508 }
3509 0  
3510 return <<'...';
3511 my $args;
3512 if ( scalar @_ == 1 ) {
3513 ( ref( $_[0] ) eq 'HASH' )
3514 || Carp::confess "Single parameters to new() must be a HASH ref";
3515 $args = +{ %{ $_[0] } };
3516 }
3517 else {
3518 $args = +{@_};
3519 }
3520 ...
3521 }
3522 0 ▶ 
Subroutine _generate_BUILDALL: not called CC=4 SCAR=30.0
3523 0 sub _generate_BUILDALL {
3524 my (undef, $metaclass) = @_;
3525 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless $metaclass->name->can("BUILD") 0 0 0
3526 return '' unless $metaclass->name->can('BUILD');
3527 0  
3528 0 my @code;
3529 0 ▶ for my $class ($metaclass->linearized_isa) {
Branch: 1 branch
BranchTrueFalseTotal
if (Mouse::Util::get_code_ref($class, "BUILD")) 0 0 0
3530 0 if (Mouse::Util::get_code_ref($class, 'BUILD')) {
3531 unshift @code, qq{${class}::BUILD(\$instance, \$args);};
3532 }
3533 0 }
3534 return join "\n", @code;
3535 }
3536  
3537 }
3538 BEGIN{ # lib/Mouse/Meta/Method/Delegation.pm
3539 2 ▶package Mouse::Meta::Method::Delegation;
Subroutine BEGIN: called CC=1 SCAR=0.0
3540 2 ▶use Mouse::Util qw(:meta); # enables strict and warnings
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
3541 use Scalar::Util;
3542 0 ▶ 
Subroutine _generate_delegation: not called CC=11 SCAR=48.8
3543 0 sub _generate_delegation{
3544 my (undef, $attr, $handle_name, $method_to_call) = @_;
3545 0  
3546 0 ▶ my @curried_args;
Branch: 1 branch
BranchTrueFalseTotal
if (ref $method_to_call eq "ARRAY") 0 0 0
3547 0 if(ref($method_to_call) eq 'ARRAY'){
3548 ($method_to_call, @curried_args) = @{$method_to_call};
3549 }
3550  
3551 0 ▶ # If it has a reader, we must use it to make method modifiers work
Condition0%0/3
$attr->get_read_method || $attr->get_read_method_ref
l!l&&r!l&&!r
000
MC/DC0%0/2
$attr->get_read_method || $attr->get_read_method_ref
$attr->get_read_method $attr->get_read_method_ref
Truth table0%0/3
A || B
A= $attr->get_read_methodB= $attr->get_read_method_ref
ABresult
1X1
011
000
3552 my $reader = $attr->get_read_method() || $attr->get_read_method_ref();
3553 0  
3554 my $can_be_optimized = $attr->{_mouse_cache_method_delegation_can_be_optimized};
3555 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $can_be_optimized) 0 0 0
3556 0 if(!defined $can_be_optimized){
3557 my $tc = $attr->type_constraint;
3558 0 ▶ $attr->{_mouse_cache_method_delegation_can_be_optimized} =
Condition0%0/18
defined $tc && $tc->is_a_type_of('Object') && ($attr->is_required || $attr->has_default || $attr->has_builder) && ($attr->is_lazy || !$attr->has_clearer)
!ll&&!rl&&r
000
defined $tc and $tc->is_a_type_of("Object") and $attr->is_required || $attr->has_default || $attr->has_builder
!ll&&!rl&&r
000
defined $tc and $tc->is_a_type_of("Object")
!ll&&!rl&&r
000
$attr->is_required or $attr->has_default or $attr->has_builder
l!l&&r!l&&!r
000
$attr->is_required or $attr->has_default
l!l&&r!l&&!r
000
$attr->is_lazy or not $attr->has_clearer
l!l&&r!l&&!r
000
MC/DC0%0/7
defined $tc && $tc->is_a_type_of('Object') && ($attr->is_required || $attr->has_default || $attr->has_builder) && ($attr->is_lazy || !$attr->has_clearer)
defined $tc $tc->is_a_type_of("Object") $attr->is_required $attr->has_default $attr->has_builder $attr->is_lazy not $attr->has_clearer
Truth table0%0/12
A and B and C or D or E && F or not(G)
A= defined $tcB= $tc->is_a_type_of("Object")C= $attr->is_requiredD= $attr->has_defaultE= $attr->has_builderF= $attr->is_lazyG= not $attr->has_clearer
ABCDEFGresult
0XXXXXX0
10XXXXX0
11000XX0
111XX000
1101X000
11001000
111XX1X1
111XX011
1101X1X1
1101X011
110011X1
11001011
3559 (defined($tc) && $tc->is_a_type_of('Object'))
3560 && ($attr->is_required || $attr->has_default || $attr->has_builder)
3561 && ($attr->is_lazy || !$attr->has_clearer);
3562 }
3563 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($can_be_optimized) { } 0 0 0
3564 if($can_be_optimized){
3565 0 ▶ # need not check the attribute value
Subroutine __ANON__: not called CC=1 SCAR=6.9
3566 0 return sub {
3567 0 return shift()->$reader()->$method_to_call(@curried_args, @_);
3568 };
3569 }
3570 else {
3571 0 ▶ # need to check the attribute value
Subroutine __ANON__: not called CC=5 SCAR=34.0
3572 0 return sub {
3573 0 my $instance = shift;
3574 my $proxy = $instance->$reader();
3575 0 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
!defined($proxy) ? : 0 0 0
ref $proxy && !builtin::blessed($proxy) ? : 0 0 0
Condition0%0/3
ref $proxy and not builtin::blessed($proxy)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $proxy and not builtin::blessed($proxy)
ref $proxy not builtin::blessed($proxy)
Truth table0%0/3
A and not(B)
A= ref $proxyB= not builtin::blessed($proxy)
ABresult
0X0
100
111
3576 my $error = !defined($proxy) ? ' is not defined'
3577 : ref($proxy) && !Scalar::Util::blessed($proxy) ? qq{ is not an object (got '$proxy')}
3578 0 ▶ : undef;
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
3579 0 if ($error) {
3580 $instance->meta->throw_error(
3581 "Cannot delegate $handle_name to $method_to_call because "
3582 . "the value of "
3583 . $attr->name
3584 . $error
3585 );
3586 0 }
3587 0 $proxy->$method_to_call(@curried_args, @_);
3588 };
3589 }
3590 }
3591  
3592  
3593 }
3594 BEGIN{ # lib/Mouse/Meta/Method/Destructor.pm
3595 2 ▶package Mouse::Meta::Method::Destructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
3596 use Mouse::Util qw(:meta); # enables strict and warnings
3597 2 ▶ 
Subroutine BEGIN: called CC=2 SCAR=7.1
Subroutine BEGIN: not called CC=1 SCAR=0.1
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'MOUSE_DEBUG'} ? : 0 2 2
3598 use constant _MOUSE_DEBUG => $ENV{MOUSE_DEBUG} ? 1 : 0;
3599 0 ▶ 
Subroutine _generate_destructor: not called CC=5 SCAR=34.0
3600 0 sub _generate_destructor{
3601 my (undef, $metaclass) = @_;
3602 0  
3603 0 my $demolishall = '';
3604 0 ▶ for my $class ($metaclass->linearized_isa) {
Branch: 1 branch
BranchTrueFalseTotal
if (Mouse::Util::get_code_ref($class, "DEMOLISH")) 0 0 0
3605 0 if (Mouse::Util::get_code_ref($class, 'DEMOLISH')) {
3606 $demolishall .= ' ' . $class
3607 . '::DEMOLISH($self, Mouse::Util::in_global_destruction());'
3608 . "\n",
3609 }
3610 }
3611 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($demolishall) 0 0 0
3612 0 if($demolishall) {
3613 $demolishall = sprintf <<'EOT', $demolishall;
3614 my $e = do{
3615 local $?;
3616 local $@;
3617 eval{
3618 %s;
3619 };
3620 $@;
3621 };
3622 no warnings 'misc';
3623 die $e if $e; # rethrow
3624 EOT
3625 }
3626 0  
3627 0 my $name = $metaclass->name;
3628 my $source = sprintf(<<'EOT', __FILE__, $name, $demolishall);
3629 #line 1 "%s"
3630 package %s;
3631 sub {
3632 my($self) = @_;
3633 return $self->Mouse::Object::DESTROY()
3634 if ref($self) ne __PACKAGE__;
3635 # DEMOLISHALL
3636 %s;
3637 return;
3638 }
3639 EOT
3640 0  
3641 warn $source if _MOUSE_DEBUG;
3642 0  
3643 0 my $code;
3644 0 my $e = do{
3645 0 local $@;
3646 0 $code = eval $source;
3647 $@;
3648 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
if $e 0 0 0
3649 0 die $e if $e;
3650 return $code;
3651 }
3652  
3653 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=4.1
3654 BEGIN{ # lib/Mouse/Meta/Module.pm
3655 2 ▶package Mouse::Meta::Module;
Subroutine BEGIN: called CC=1 SCAR=0.0
3656 use Mouse::Util qw/:meta/; # enables strict and warnings
3657 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
3658 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
3659 use Scalar::Util ();
3660 2  
3661 my %METAS;
3662 2  
3663 if(Mouse::Util::MOUSE_XS){
3664 # register meta storage for performance
3665 Mouse::Util::__register_metaclass_storage(\%METAS, 0);
3666  
3667 0 ▶ # ensure thread safety
Subroutine __ANON__: not called CC=1 SCAR=6.9
3668 *CLONE = sub { Mouse::Util::__register_metaclass_storage(\%METAS, 1) };
3669 }
3670 12 ▶ 
Subroutine initialize: called CC=4 SCAR=15.6
Pod undocumented
3671 12 sub initialize {
3672 my($class, $package_name, @args) = @_;
3673 12 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
$package_name and not ref $package_name or $class->throw_error("You must pass a package name and it cannot be blessed") 12 0 12
Condition33%1/3
$package_name and not ref $package_name
!ll&&!rl&&r
0012
MC/DC0%0/2
$package_name and not ref $package_name
$package_name not ref $package_name
Truth table33%1/3
A and not(B)
A= $package_nameB= not ref $package_name
ABresult
0X0
100
111
3674 ($package_name && !ref($package_name))
3675 || $class->throw_error("You must pass a package name and it cannot be blessed");
3676 12 ▶ 
Condition66%2/3
$METAS{$package_name} ||= $class->_construct_meta("package", $package_name, @args)
l!l&&r!l&&!r
840
MC/DC0%0/2
$METAS{$package_name} ||= $class->_construct_meta("package", $package_name, @args)
$METAS{$package_name} $class->_construct_meta("package", $package_name, @args)
Truth table66%2/3
A ||= B
A= $METAS{$package_name}B= $class->_construct_meta("package", $package_name, @args)
ABresult
1X1
011
000
3677 return $METAS{$package_name}
3678 ||= $class->_construct_meta(package => $package_name, @args);
3679 }
3680 0 ▶ 
Subroutine reinitialize: not called CC=5 SCAR=34.0
Pod undocumented
3681 0 sub reinitialize {
3682 my($class, $package_name, @args) = @_;
3683 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ref $package_name 0 0 0
3684 $package_name = $package_name->name if ref $package_name;
3685 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
$package_name and not ref $package_name or $class->throw_error("You must pass a package name and it cannot be blessed") 0 0 0
Condition0%0/3
$package_name and not ref $package_name
!ll&&!rl&&r
000
MC/DC0%0/2
$package_name and not ref $package_name
$package_name not ref $package_name
Truth table0%0/3
A and not(B)
A= $package_nameB= not ref $package_name
ABresult
0X0
100
111
3686 ($package_name && !ref($package_name))
3687 || $class->throw_error("You must pass a package name and it cannot be blessed");
3688 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $METAS{$package_name}) 0 0 0
3689 0 if(exists $METAS{$package_name}) {
3690 unshift @args, %{ $METAS{$package_name} };
3691 0 }
3692 0 delete $METAS{$package_name};
3693 return $class->initialize($package_name, @args);
3694 }
3695 0 ▶ 
Subroutine _class_of: not called CC=3 SCAR=24.8
3696 0 sub _class_of{
3697 0 ▶ my($class_or_instance) = @_;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $class_or_instance 0 0 0
3698 0 ▶ return undef unless defined $class_or_instance;
Condition0%0/3
ref $class_or_instance || $class_or_instance
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class_or_instance || $class_or_instance
ref $class_or_instance $class_or_instance
Truth table0%0/3
A || B
A= ref $class_or_instanceB= $class_or_instance
ABresult
1X1
011
000
3699 return $METAS{ ref($class_or_instance) || $class_or_instance };
3700 }
3701  
3702 # Means of accessing all the metaclasses that have
3703 # been initialized thus far.
3704 # The public versions are aliased into Mouse::Util::*.
3705 0 ▶#sub _get_all_metaclasses { %METAS }
Subroutine _get_all_metaclass_instances: not called CC=1 SCAR=6.9
3706 0 ▶sub _get_all_metaclass_instances { values %METAS }
Subroutine _get_all_metaclass_names: not called CC=1 SCAR=6.9
3707 20 ▶sub _get_all_metaclass_names { keys %METAS }
Subroutine _get_metaclass_by_name: called CC=1 SCAR=0.0
3708 sub _get_metaclass_by_name { $METAS{$_[0]} }
3709 #sub _store_metaclass_by_name { $METAS{$_[0]} = $_[1] }
3710 #sub _weaken_metaclass { weaken($METAS{$_[0]}) }
3711 #sub _does_metaclass_exist { defined $METAS{$_[0]} }
3712 #sub _remove_metaclass_by_name { delete $METAS{$_[0]} }
3713  
3714 sub name;
3715  
3716 sub namespace;
3717  
3718 # add_attribute is an abstract method
3719 0 ▶ 
Subroutine get_attribute_map: not called CC=1 SCAR=6.9
Pod undocumented
3720 0 sub get_attribute_map { # DEPRECATED
3721 0 Carp::cluck('get_attribute_map() has been deprecated. Use get_attribute_list() and get_attribute() instead');
3722 return $_[0]->{attributes};
3723 }
3724 0 ▶ 
Subroutine has_attribute: not called CC=1 SCAR=6.9
Pod undocumented
3725 0 ▶sub has_attribute { exists $_[0]->{attributes}->{$_[1]} }
Subroutine get_attribute: not called CC=1 SCAR=6.9
Pod undocumented
3726 0 ▶sub get_attribute { $_[0]->{attributes}->{$_[1]} }
Subroutine remove_attribute: not called CC=1 SCAR=6.9
Pod undocumented
3727 sub remove_attribute { delete $_[0]->{attributes}->{$_[1]} }
3728 0 ▶ 
Subroutine get_attribute_list: not called CC=1 SCAR=6.9
Pod undocumented
3729 sub get_attribute_list{ keys %{$_[0]->{attributes}} }
3730  
3731 2 # XXX: not completely compatible with Moose
3732 my %foreign = map{ $_ => undef } qw(
3733 Mouse Mouse::Role Mouse::Util Mouse::Util::TypeConstraints
3734 Carp Scalar::Util List::Util
3735 builtin
3736 0 ▶);
Subroutine _get_method_body: not called CC=3 SCAR=24.8
3737 0 sub _get_method_body {
3738 0 my($self, $method_name) = @_;
3739 0 ▶ my $code = Mouse::Util::get_code_ref($self->{package}, $method_name);
Branch: 1 branch
BranchTrueFalseTotal
$code && !exists($foreign{Mouse::Util::get_code_package($code)}) ? : 0 0 0
Condition0%0/3
$code and not exists $foreign{Mouse::Util::get_code_package($code)}
!ll&&!rl&&r
000
MC/DC0%0/2
$code and not exists $foreign{Mouse::Util::get_code_package($code)}
$code not exists $foreign{Mouse::Util::get_code_package($code)}
Truth table0%0/3
A and not(B)
A= $codeB= not exists $foreign{Mouse::Util::get_code_package($code)}
ABresult
0X0
100
111
3740 return $code && !exists $foreign{ Mouse::Util::get_code_package($code) }
3741 ? $code
3742 : undef;
3743 }
3744  
3745 sub add_method;
3746 0 ▶ 
Subroutine has_method: not called CC=3 SCAR=24.8
Pod undocumented
3747 0 sub has_method {
3748 0 ▶ my($self, $method_name) = @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $method_name or $self->throw_error("You must define a method name") 0 0 0
3749 defined($method_name)
3750 or $self->throw_error('You must define a method name');
3751 0 ▶ 
Condition0%0/3
defined $self->{'methods'}{$method_name} || defined $self->_get_method_body($method_name)
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $self->{'methods'}{$method_name} || defined $self->_get_method_body($method_name)
defined $self->{'methods'}{$method_name} defined $self->_get_method_body($method_name)
Truth table0%0/3
A || B
A= defined $self->{'methods'}{$method_name}B= defined $self->_get_method_body($method_name)
ABresult
1X1
011
000
3752 return defined( $self->{methods}{$method_name} )
3753 || defined( $self->_get_method_body($method_name) );
3754 }
3755 0 ▶ 
Subroutine get_method_body: not called CC=3 SCAR=24.8
Pod undocumented
3756 0 sub get_method_body {
3757 0 ▶ my($self, $method_name) = @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $method_name or $self->throw_error("You must define a method name") 0 0 0
3758 defined($method_name)
3759 or $self->throw_error('You must define a method name');
3760 0 ▶ 
Condition0%0/3
$self->{"methods"}{$method_name} ||= $self->_get_method_body($method_name)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"methods"}{$method_name} ||= $self->_get_method_body($method_name)
$self->{"methods"}{$method_name} $self->_get_method_body($method_name)
Truth table0%0/3
A ||= B
A= $self->{"methods"}{$method_name}B= $self->_get_method_body($method_name)
ABresult
1X1
011
000
3761 return $self->{methods}{$method_name}
3762 ||= $self->_get_method_body($method_name);
3763 }
3764 0 ▶ 
Subroutine get_method: not called CC=2 SCAR=17.9
Pod undocumented
3765 0 sub get_method {
3766 my($self, $method_name) = @_;
3767 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $self->get_method_body($method_name)) 0 0 0
3768 0 if(my $code = $self->get_method_body($method_name)){
3769 return Mouse::Util::load_class($self->method_metaclass)->wrap(
3770 body => $code,
3771 name => $method_name,
3772 package => $self->name,
3773 associated_metaclass => $self,
3774 );
3775 }
3776 0  
3777 return undef;
3778 }
3779 0 ▶ 
Subroutine get_method_list: not called CC=1 SCAR=6.9
Pod undocumented
3780 0 sub get_method_list {
3781 my($self) = @_;
3782 0  
3783 return grep { $self->has_method($_) } keys %{ $self->namespace };
3784 }
3785 0 ▶ 
Subroutine _collect_methods: not called CC=5 SCAR=34.0
3786 0 sub _collect_methods { # Mouse specific, used for method modifiers
3787 my($meta, @args) = @_;
3788 0  
3789 0 my @methods;
3790 0 ▶ foreach my $arg(@args){
Branch: 1 branch
BranchTrueFalseTotal
if (my $type = ref $arg) { } 0 0 0
3791 0 ▶ if(my $type = ref $arg){
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'Regexp') { } 0 0 0
elsif ($type eq 'ARRAY') { } 0 0 0
3792 0 if($type eq 'Regexp'){
3793 push @methods, grep { $_ =~ $arg } $meta->get_all_method_names;
3794 }
3795 0 elsif($type eq 'ARRAY'){
3796 push @methods, @{$arg};
3797 }
3798 0 else{
3799 0 my $subname = ( caller(1) )[3];
3800 $meta->throw_error(
3801 sprintf(
3802 'Methods passed to %s must be provided as a list,'
3803 . ' ArrayRef or regular expression, not %s',
3804 $subname,
3805 $type,
3806 )
3807 );
3808 }
3809 }
3810 0 else{
3811 push @methods, $arg;
3812 }
3813 0 }
3814 return @methods;
3815 }
3816 2  
3817 2 my $ANON_SERIAL = 0; # anonymous class/role id
3818 my %IMMORTALS; # immortal anonymous classes
3819 0 ▶ 
Subroutine create: not called CC=31 SCAR=68.3
Pod undocumented
3820 0 sub create {
3821 my($self, $package_name, %options) = @_;
3822 0 ▶ 
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
3823 0 ▶ my $class = ref($self) || $self;
Branch: 1 branch
BranchTrueFalseTotal
if @_ < 2 0 0 0
3824 $self->throw_error('You must pass a package name') if @_ < 2;
3825 0  
3826 0 ▶ my $superclasses;
Branch: 1 branch
BranchTrueFalseTotal
if (exists $options{"superclasses"}) 0 0 0
3827 0 ▶ if(exists $options{superclasses}){
Branch: 1 branch
BranchTrueFalseTotal
if (Mouse::Util::is_a_metarole($self)) { } 0 0 0
3828 0 if(Mouse::Util::is_a_metarole($self)){
3829 delete $options{superclasses};
3830 }
3831 0 else{
3832 0 ▶ $superclasses = delete $options{superclasses};
Branch: 1 branch
BranchTrueFalseTotal
ref $superclasses eq "ARRAY" or $self->throw_error("You must pass an ARRAY ref of superclasses") 0 0 0
3833 (ref $superclasses eq 'ARRAY')
3834 || $self->throw_error("You must pass an ARRAY ref of superclasses");
3835 }
3836 }
3837 0  
3838 0 ▶ my $attributes = delete $options{attributes};
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attributes) 0 0 0
3839 0 ▶ if(defined $attributes){
Branch: 1 branch
BranchTrueFalseTotal
ref $attributes eq "ARRAY" or ref $attributes eq "HASH" or $self->throw_error("You must pass an ARRAY ref of attributes") 0 0 0
Condition0%0/3
ref $attributes eq "ARRAY" or ref $attributes eq "HASH"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $attributes eq "ARRAY" or ref $attributes eq "HASH"
ref $attributes eq "ARRAY" ref $attributes eq "HASH"
Truth table0%0/3
A or B
A= ref $attributes eq "ARRAY"B= ref $attributes eq "HASH"
ABresult
1X1
011
000
3840 (ref $attributes eq 'ARRAY' || ref $attributes eq 'HASH')
3841 || $self->throw_error("You must pass an ARRAY ref of attributes");
3842 0 }
3843 0 ▶ my $methods = delete $options{methods};
Branch: 1 branch
BranchTrueFalseTotal
if (defined $methods) 0 0 0
3844 0 ▶ if(defined $methods){
Branch: 1 branch
BranchTrueFalseTotal
ref $methods eq "HASH" or $self->throw_error("You must pass a HASH ref of methods") 0 0 0
3845 (ref $methods eq 'HASH')
3846 || $self->throw_error("You must pass a HASH ref of methods");
3847 0 }
3848 0 ▶ my $roles = delete $options{roles};
Branch: 1 branch
BranchTrueFalseTotal
if (defined $roles) 0 0 0
3849 0 ▶ if(defined $roles){
Branch: 1 branch
BranchTrueFalseTotal
ref $roles eq "ARRAY" or $self->throw_error("You must pass an ARRAY ref of roles") 0 0 0
3850 (ref $roles eq 'ARRAY')
3851 || $self->throw_error("You must pass an ARRAY ref of roles");
3852 0 }
3853 my $mortal;
3854 my $cache_key;
3855 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $package_name) 0 0 0
3856 0 if(!defined $package_name){ # anonymous
3857 $mortal = !$options{cache};
3858  
3859 0 ▶ # anonymous but immortal
Branch: 1 branch
BranchTrueFalseTotal
unless ($mortal) 0 0 0
3860 if(!$mortal){
3861 # something like Super::Class|Super::Class::2=Role|Role::1
3862 0 ▶ $cache_key = join '=' => (
Condition0%0/2
$superclasses || []
l!l
00
MC/DC0%0/1
$superclasses || []
$superclasses
Truth table0%0/2
A
A= $superclasses
Aresult
11
00
3863 0 ▶ join('|', @{$superclasses || []}),
Condition0%0/2
$roles || []
l!l
00
MC/DC0%0/1
$roles || []
$roles
Truth table0%0/2
A
A= $roles
Aresult
11
00
3864 join('|', sort @{$roles || []}),
3865 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
if exists $IMMORTALS{$cache_key} 0 0 0
3866 return $IMMORTALS{$cache_key} if exists $IMMORTALS{$cache_key};
3867 0 }
3868 0 $options{anon_serial_id} = ++$ANON_SERIAL;
3869 $package_name = $class . '::__ANON__::' . $ANON_SERIAL;
3870 }
3871  
3872  
3873 # instantiate a module
3874 0 ▶ {
Subroutine BEGIN: called CC=1 SCAR=0.2
3875 0 ▶ no strict 'refs';
Branch: 1 branch
BranchTrueFalseTotal
if exists $options{"version"} 0 0 0
3876 0 ▶ ${ $package_name . '::VERSION' } = delete $options{version} if exists $options{version};
Branch: 1 branch
BranchTrueFalseTotal
if exists $options{"authority"} 0 0 0
3877 ${ $package_name . '::AUTHORITY' } = delete $options{authority} if exists $options{authority};
3878 }
3879 0  
3880 my $meta = $self->initialize( $package_name, %options);
3881 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $mortal 0 0 0
3882 Scalar::Util::weaken($METAS{$package_name})
3883 if $mortal;
3884 0 ▶ 
Subroutine __ANON__: not called CC=2 SCAR=17.9
3885 0 ▶ $meta->add_method(meta => sub {
Condition0%0/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
3886 0 $self->initialize(ref($_[0]) || $_[0]);
3887 });
3888 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if defined $superclasses 0 0 0
3889 $meta->superclasses(@{$superclasses})
3890 if defined $superclasses;
3891  
3892 # NOTE:
3893 # process attributes first, so that they can
3894 # install accessors, but locally defined methods
3895 # can then overwrite them. It is maybe a little odd, but
3896 0 ▶ # I think this should be the order of things.
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attributes) 0 0 0
3897 0 ▶ if (defined $attributes) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attributes eq 'ARRAY') { } 0 0 0
3898 if(ref($attributes) eq 'ARRAY'){
3899 0 # array of Mouse::Meta::Attribute
3900 0 foreach my $attr (@{$attributes}) {
3901 $meta->add_attribute($attr);
3902 }
3903 }
3904 else{
3905 0 ▶ # hash map of name and attribute spec pairs
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$attributes;}) 0 0 0
3906 0 while(my($name, $attr) = each %{$attributes}){
3907 $meta->add_attribute($name => $attr);
3908 }
3909 }
3910 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $methods) 0 0 0
3911 0 ▶ if (defined $methods) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$methods;}) 0 0 0
3912 0 while(my($method_name, $method_body) = each %{$methods}){
3913 $meta->add_method($method_name, $method_body);
3914 }
3915 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $roles and not $options{"in_application_to_instance"}) 0 0 0
Condition0%0/3
defined $roles and not $options{"in_application_to_instance"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $roles and not $options{"in_application_to_instance"}
defined $roles not $options{"in_application_to_instance"}
Truth table0%0/3
A and not(B)
A= defined $rolesB= not $options{"in_application_to_instance"}
ABresult
0X0
100
111
3916 0 if (defined $roles and !$options{in_application_to_instance}){
3917 Mouse::Util::apply_all_roles($package_name, @{$roles});
3918 }
3919 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($cache_key) 0 0 0
3920 0 if($cache_key){
3921 $IMMORTALS{$cache_key} = $meta;
3922 }
3923 0  
3924 return $meta;
3925 }
3926 0 ▶ 
Subroutine DESTROY: not called CC=7 SCAR=37.8
3927 0 sub DESTROY{
3928 my($self) = @_;
3929 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if Mouse::Util::in_global_destruction() 0 0 0
3930 return if Mouse::Util::in_global_destruction();
3931 0  
3932 0 ▶ my $serial_id = $self->{anon_serial_id};
Branch: 1 branch
BranchTrueFalseTotal
unless $serial_id 0 0 0
3933 return if !$serial_id;
3934  
3935 0 ▶ # XXX: cleaning stash with threads causes panic/SEGV on legacy perls.
Branch: 1 branch
BranchTrueFalseTotal
if (exists $INC{"threads.pm"}) 0 0 0
3936 if(exists $INC{'threads.pm'}) {
3937 # (caller)[2] indicates the caller's line number,
3938 0 ▶ # which is zero when the current thread is joining (destroying).
Branch: 1 branch
BranchTrueFalseTotal
if (caller)[2] == 0 0 0 0
3939 return if( (caller)[2] == 0);
3940 }
3941  
3942 # clean up mortal anonymous class stuff
3943  
3944 0 ▶ # @ISA is a magical variable, so we must clear it manually.
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"superclasses"} and scalar @{$self->{"superclasses"};} > 0 0 0 0
Condition0%0/3
exists $self->{"superclasses"} and scalar @{$self->{"superclasses"};} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"superclasses"} and scalar @{$self->{"superclasses"};} > 0
exists $self->{"superclasses"} scalar @{$self->{"superclasses"};} > 0
Truth table0%0/3
A and B
A= exists $self->{"superclasses"}B= scalar @{$self->{"superclasses"};} > 0
ABresult
0X0
100
111
3945 @{$self->{superclasses}} = () if exists $self->{superclasses} && scalar(@{$self->{superclasses}}) > 0;
3946  
3947 0 # Then, clear the symbol table hash
3948 %{$self->namespace} = ();
3949 0  
3950 0 my $name = $self->name;
3951 delete $METAS{$name};
3952 0  
3953 2 ▶ $name =~ s/ $serial_id \z//xms;
Subroutine BEGIN: called CC=1 SCAR=0.0
3954 0 no strict 'refs';
3955 0 delete ${$name}{ $serial_id . '::' };
3956 return;
3957 }
3958  
3959  
3960 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
3961 BEGIN{ # lib/Mouse/Meta/Role.pm
3962 2 ▶package Mouse::Meta::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3963 use Mouse::Util qw(:meta); # enables strict and warnings
3964 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
3965 2 use Mouse::Meta::Module;
3966 our @ISA = qw(Mouse::Meta::Module);
3967  
3968 sub method_metaclass;
3969 0 ▶ 
Subroutine _construct_meta: not called CC=3 SCAR=24.8
3970 0 sub _construct_meta {
3971 my $class = shift;
3972 0  
3973 my %args = @_;
3974 0  
3975 0 $args{methods} = {};
3976 0 $args{attributes} = {};
3977 0 $args{required_methods} = [];
3978 $args{roles} = [];
3979 0 ▶ 
Condition0%0/3
ref $class || $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table0%0/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
3980 0 ▶ my $self = bless \%args, ref($class) || $class;
Branch: 1 branch
BranchTrueFalseTotal
if ($class ne __PACKAGE__) 0 0 0
3981 0 if($class ne __PACKAGE__){
3982 $self->meta->_initialize_object($self, \%args);
3983 0 }
3984 return $self;
3985 }
3986 0 ▶ 
Subroutine create_anon_role: not called CC=1 SCAR=6.9
Pod undocumented
3987 0 sub create_anon_role{
3988 0 my $self = shift;
3989 return $self->create(undef, @_);
3990 }
3991  
3992 sub is_anon_role;
3993  
3994 sub get_roles;
3995 0 ▶ 
Subroutine calculate_all_roles: not called CC=1 SCAR=6.9
Pod undocumented
3996 0 sub calculate_all_roles {
3997 0 my $self = shift;
3998 0 my %seen;
3999 0 return grep { !$seen{ $_->name }++ }
4000 ($self, map { $_->calculate_all_roles } @{ $self->get_roles });
4001 }
4002 0 ▶ 
Subroutine get_required_method_list: not called CC=1 SCAR=6.9
Pod undocumented
4003 0 sub get_required_method_list{
4004 return @{ $_[0]->{required_methods} };
4005 }
4006 0 ▶ 
Subroutine add_required_methods: not called CC=2 SCAR=17.9
Pod undocumented
4007 0 sub add_required_methods {
4008 0 my($self, @methods) = @_;
4009 0 ▶ my %required = map{ $_ => 1 } @{$self->{required_methods}};
Condition0%0/3
$required{$_}++ || $self->has_method($_)
l!l&&r!l&&!r
000
MC/DC0%0/2
$required{$_}++ || $self->has_method($_)
$required{$_}++ $self->has_method($_)
Truth table0%0/3
A || B
A= $required{$_}++B= $self->has_method($_)
ABresult
1X1
011
000
4010 0 push @{$self->{required_methods}}, grep{ !$required{$_}++ && !$self->has_method($_) } @methods;
4011 return;
4012 }
4013 0 ▶ 
Subroutine requires_method: not called CC=1 SCAR=6.9
Pod undocumented
4014 0 sub requires_method {
4015 0 my($self, $name) = @_;
4016 return scalar( grep{ $_ eq $name } @{ $self->{required_methods} } ) != 0;
4017 }
4018 0 ▶ 
Subroutine add_attribute: not called CC=2 SCAR=17.9
Pod undocumented
4019 0 sub add_attribute {
4020 0 my $self = shift;
4021 my $name = shift;
4022 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 0 0
4023 0 $self->{attributes}->{$name} = (@_ == 1) ? $_[0] : { @_ };
4024 return;
4025 }
4026 0 ▶ 
Subroutine apply: not called CC=1 SCAR=6.9
Pod undocumented
4027 0 sub apply {
4028 0 my $self = shift;
4029 my $consumer = shift;
4030 0  
4031 0 require 'Mouse/Meta/Role/Application.pm';
4032 return Mouse::Meta::Role::Application->new(@_)->apply($self, $consumer);
4033 }
4034 0 ▶ 
Subroutine combine: not called CC=1 SCAR=6.9
Pod undocumented
4035 0 sub combine {
4036 my($self, @role_specs) = @_;
4037 0  
4038 0 require 'Mouse/Meta/Role/Composite.pm';
4039 return Mouse::Meta::Role::Composite->new(roles => \@role_specs);
4040 }
4041  
4042 sub add_before_method_modifier;
4043 sub add_around_method_modifier;
4044 sub add_after_method_modifier;
4045  
4046 sub get_before_method_modifiers;
4047 sub get_around_method_modifiers;
4048 sub get_after_method_modifiers;
4049 0 ▶ 
Subroutine add_override_method_modifier: not called CC=2 SCAR=17.9
Pod undocumented
4050 0 sub add_override_method_modifier{
4051 my($self, $method_name, $method) = @_;
4052 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_method($method_name)) 0 0 0
4053 if($self->has_method($method_name)){
4054 # This error happens in the override keyword or during role composition,
4055 0 # so I added a message, "A local method of ...", only for compatibility (gfx)
4056 $self->throw_error("Cannot add an override of method '$method_name' "
4057 . "because there is a local version of '$method_name'"
4058 . "(A local method of the same name as been found)");
4059 }
4060 0  
4061 $self->{override_method_modifiers}->{$method_name} = $method;
4062 }
4063 0 ▶ 
Subroutine get_override_method_modifier: not called CC=1 SCAR=6.9
Pod undocumented
4064 0 sub get_override_method_modifier {
4065 0 my ($self, $method_name) = @_;
4066 return $self->{override_method_modifiers}->{$method_name};
4067 }
4068 0 ▶ 
Subroutine does_role: not called CC=6 SCAR=37.4
Pod undocumented
4069 0 sub does_role {
4070 my ($self, $role_name) = @_;
4071 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
defined $role_name or $self->throw_error("You must supply a role name to look for") 0 0 0
4072 (defined $role_name)
4073 || $self->throw_error("You must supply a role name to look for");
4074 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ref $role_name 0 0 0
4075 $role_name = $role_name->name if ref $role_name;
4076  
4077 0 ▶ # if we are it,.. then return true
Branch: 1 branch
BranchTrueFalseTotal
if $role_name eq $self->name 0 0 0
4078 return 1 if $role_name eq $self->name;
4079 0 # otherwise.. check our children
4080 0 ▶ for my $role (@{ $self->get_roles }) {
Branch: 1 branch
BranchTrueFalseTotal
if $role->does_role($role_name) 0 0 0
4081 return 1 if $role->does_role($role_name);
4082 0 }
4083 return 0;
4084 }
4085  
4086 }
4087 BEGIN{ # lib/Mouse/Meta/Role/Application.pm
4088 2 ▶package Mouse::Meta::Role::Application;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
4089 use Mouse::Util qw(:meta);
4090 0 ▶ 
Subroutine new: not called CC=11 SCAR=48.8
Pod undocumented
4091 0 sub new {
4092 0 my $class = shift;
4093 my $args = $class->Mouse::Object::BUILDARGS(@_);
4094 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"exclude"} or exists $args->{"alias"}) 0 0 0
Condition0%0/3
exists $args->{"exclude"} or exists $args->{"alias"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $args->{"exclude"} or exists $args->{"alias"}
exists $args->{"exclude"} exists $args->{"alias"}
Truth table0%0/3
A or B
A= exists $args->{"exclude"}B= exists $args->{"alias"}
ABresult
1X1
011
000
4095 0 if(exists $args->{exclude} or exists $args->{alias}) {
4096 warnings::warnif(deprecated =>
4097 'The alias and excludes options for role application have been'
4098 . ' renamed -alias and -exclude');
4099 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"alias"} and not exists $args->{"-alias"}) 0 0 0
Condition0%0/3
$args->{"alias"} and not exists $args->{"-alias"}
!ll&&!rl&&r
000
MC/DC0%0/2
$args->{"alias"} and not exists $args->{"-alias"}
$args->{"alias"} not exists $args->{"-alias"}
Truth table0%0/3
A and not(B)
A= $args->{"alias"}B= not exists $args->{"-alias"}
ABresult
0X0
100
111
4100 0 if($args->{alias} && !exists $args->{-alias}){
4101 $args->{-alias} = $args->{alias};
4102 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"excludes"} and not exists $args->{"-excludes"}) 0 0 0
Condition0%0/3
$args->{"excludes"} and not exists $args->{"-excludes"}
!ll&&!rl&&r
000
MC/DC0%0/2
$args->{"excludes"} and not exists $args->{"-excludes"}
$args->{"excludes"} not exists $args->{"-excludes"}
Truth table0%0/3
A and not(B)
A= $args->{"excludes"}B= not exists $args->{"-excludes"}
ABresult
0X0
100
111
4103 0 if($args->{excludes} && !exists $args->{-excludes}){
4104 $args->{-excludes} = $args->{excludes};
4105 }
4106 }
4107 0  
4108 0 ▶ $args->{aliased_methods} = {};
Branch: 1 branch
BranchTrueFalseTotal
if (my $alias = $args->{"-alias"}) 0 0 0
4109 0 if(my $alias = $args->{-alias}){
4110 @{$args->{aliased_methods}}{ values %{$alias} } = ();
4111 }
4112 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (my $excludes = $args->{"-excludes"}) 0 0 0
4113 0 if(my $excludes = $args->{-excludes}){
4114 0 ▶ $args->{-excludes} = {}; # replace with a hash ref
Branch: 1 branch
BranchTrueFalseTotal
if (ref $excludes) { } 0 0 0
4115 0 if(ref $excludes){
4116 %{$args->{-excludes}} = (map{ $_ => undef } @{$excludes});
4117 }
4118 0 else{
4119 $args->{-excludes}{$excludes} = undef;
4120 }
4121 0 }
4122 0 ▶ my $self = bless $args, $class;
Branch: 1 branch
BranchTrueFalseTotal
if ($class ne __PACKAGE__) 0 0 0
4123 0 if($class ne __PACKAGE__){
4124 $self->meta->_initialize_object($self, $args);
4125 0 }
4126 return $self;
4127 }
4128 0 ▶ 
Subroutine apply: not called CC=5 SCAR=34.0
Pod undocumented
4129 0 sub apply {
4130 0 my($self, $role, $consumer, @extra) = @_;
4131 my $instance;
4132 0 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if (Mouse::Util::is_a_metaclass($consumer)) { } 0 0 0
elsif (Mouse::Util::is_a_metarole($consumer)) { } 0 0 0
4133 0 if(Mouse::Util::is_a_metaclass($consumer)) { # Application::ToClass
4134 $self->{_to} = 'class';
4135 }
4136 0 elsif(Mouse::Util::is_a_metarole($consumer)) { # Application::ToRole
4137 $self->{_to} = 'role';
4138 }
4139 0 else { # Appplication::ToInstance
4140 0 $self->{_to} = 'instance';
4141 $instance = $consumer;
4142 0  
4143 0 ▶ my $meta = Mouse::Util::class_of($instance);
Condition0%0/2
$meta || 'Mouse::Meta::Class'
l!l
00
MC/DC0%0/1
$meta || 'Mouse::Meta::Class'
$meta
Truth table0%0/2
A
A= $meta
Aresult
11
00
4144 $consumer = ($meta || 'Mouse::Meta::Class')
4145 ->create_anon_class(
4146 superclasses => [ref $instance],
4147 roles => [$role],
4148 cache => 0,
4149  
4150 in_application_to_instance => 1, # suppress to apply roles
4151 );
4152 }
4153  
4154 0 #$self->check_role_exclusions($role, $consumer, @extra);
4155 $self->check_required_methods($role, $consumer, @extra);
4156 #$self->check_required_attributes($role, $consumer, @extra);
4157 0  
4158 0 $self->apply_attributes($role, $consumer, @extra);
4159 $self->apply_methods($role, $consumer, @extra);
4160 #$self->apply_override_method_modifiers($role, $consumer, @extra);
4161 #$self->apply_before_method_modifiers($role, $consumer, @extra);
4162 #$self->apply_around_method_modifiers($role, $consumer, @extra);
4163 0 #$self->apply_after_method_modifiers($role, $consumer, @extra);
4164 $self->apply_modifiers($role, $consumer, @extra);
4165 0  
4166 $self->_append_roles($role, $consumer);
4167 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $instance) 0 0 0
4168 if(defined $instance){ # Application::ToInstance
4169 0 # rebless instance
4170 0 bless $instance, $consumer->name;
4171 $consumer->_initialize_object($instance, $instance, 1);
4172 }
4173 0  
4174 return;
4175 }
4176 0 ▶ 
Subroutine check_required_methods: not called CC=8 SCAR=42.8
Pod undocumented
4177 0 sub check_required_methods {
4178 my($self, $role, $consumer) = @_;
4179 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_to'} eq 'role') { } 0 0 0
4180 0 if($self->{_to} eq 'role'){
4181 $consumer->add_required_methods($role->get_required_method_list);
4182 }
4183 0 else{ # to class or instance
4184 my $consumer_class_name = $consumer->name;
4185 0  
4186 0 my @missing;
4187 0 ▶ foreach my $method_name(@{$role->{required_methods}}){
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"aliased_methods"}{$method_name} 0 0 0
4188 0 ▶ next if exists $self->{aliased_methods}{$method_name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $role->{"methods"}{$method_name} 0 0 0
4189 0 ▶ next if exists $role->{methods}{$method_name};
Branch: 1 branch
BranchTrueFalseTotal
if $consumer_class_name->can($method_name) 0 0 0
4190 next if $consumer_class_name->can($method_name);
4191 0  
4192 push @missing, $method_name;
4193 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
if (@missing) 0 0 0
4194 0 ▶ if(@missing){
Branch: 1 branch
BranchTrueFalseTotal
@missing == 1 ? : 0 0 0
4195 $role->throw_error(sprintf "'%s' requires the method%s %s to be implemented by '%s'",
4196 $role->name,
4197 (@missing == 1 ? '' : 's'), # method or methods
4198 Mouse::Util::quoted_english_list(@missing),
4199 $consumer_class_name);
4200 }
4201 }
4202 0  
4203 return;
4204 }
4205 0 ▶ 
Subroutine apply_methods: not called CC=8 SCAR=42.8
Pod undocumented
4206 0 sub apply_methods {
4207 my($self, $role, $consumer) = @_;
4208 0  
4209 0 my $alias = $self->{-alias};
4210 my $excludes = $self->{-excludes};
4211 0  
4212 0 ▶ foreach my $method_name($role->get_method_list){
Branch: 1 branch
BranchTrueFalseTotal
if $method_name eq "meta" 0 0 0
4213 next if $method_name eq 'meta';
4214 0  
4215 my $code = $role->get_method_body($method_name);
4216 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $excludes->{$method_name}) 0 0 0
4217 0 ▶ if(!exists $excludes->{$method_name}){
Branch: 1 branch
BranchTrueFalseTotal
unless ($consumer->has_method($method_name)) 0 0 0
4218 if(!$consumer->has_method($method_name)){
4219 0 # The third argument $role is used in Role::Composite
4220 $consumer->add_method($method_name => $code, $role);
4221 }
4222 }
4223 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $alias->{$method_name}) 0 0 0
4224 0 if(exists $alias->{$method_name}){
4225 my $dstname = $alias->{$method_name};
4226 0  
4227 my $dstcode = $consumer->get_method_body($dstname);
4228 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dstcode and $dstcode != $code) { } 0 0 0
Condition0%0/3
defined $dstcode and $dstcode != $code
!ll&&!rl&&r
000
MC/DC0%0/2
defined $dstcode and $dstcode != $code
defined $dstcode $dstcode != $code
Truth table0%0/3
A and B
A= defined $dstcodeB= $dstcode != $code
ABresult
0X0
100
111
4229 0 if(defined($dstcode) && $dstcode != $code){
4230 $role->throw_error("Cannot create a method alias if a local method of the same name exists");
4231 }
4232 0 else{
4233 $consumer->add_method($dstname => $code, $role);
4234 }
4235 }
4236 }
4237 0  
4238 return;
4239 }
4240 0 ▶ 
Subroutine apply_attributes: not called CC=3 SCAR=24.8
Pod undocumented
4241 0 sub apply_attributes {
4242 my($self, $role, $consumer) = @_;
4243 0  
4244 0 ▶ for my $attr_name ($role->get_attribute_list) {
Branch: 1 branch
BranchTrueFalseTotal
if $consumer->has_attribute($attr_name) 0 0 0
4245 next if $consumer->has_attribute($attr_name);
4246 0  
4247 $consumer->add_attribute($attr_name
4248 => $role->get_attribute($attr_name));
4249 0 }
4250 return;
4251 }
4252 0 ▶ 
Subroutine apply_modifiers: not called CC=8 SCAR=42.8
Pod undocumented
4253 0 sub apply_modifiers {
4254 my($self, $role, $consumer) = @_;
4255 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (my $modifiers = $role->{"override_method_modifiers"}) 0 0 0
4256 0 if(my $modifiers = $role->{override_method_modifiers}){
4257 foreach my $method_name (keys %{$modifiers}){
4258 0 $consumer->add_override_method_modifier(
4259 $method_name => $modifiers->{$method_name});
4260 }
4261 }
4262 0  
4263 0 ▶ for my $modifier_type (qw/before around after/) {
Branch: 1 branch
BranchTrueFalseTotal
my $table = $$role{"${modifier_type}_method_modifiers"} or next 0 0 0
4264 my $table = $role->{"${modifier_type}_method_modifiers"}
4265 or next;
4266 0  
4267 my $add_modifier = "add_${modifier_type}_method_modifier";
4268 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$table;}) 0 0 0
4269 0 while(my($method_name, $modifiers) = each %{$table}){
4270 foreach my $code(@{ $modifiers }) {
4271 0 ▶ # skip if the modifier is already applied
Branch: 1 branch
BranchTrueFalseTotal
if $$consumer{"_applied_$modifier_type"}{join $;, $method_name, $code}++ 0 0 0
4272 0 next if $consumer->{"_applied_$modifier_type"}{$method_name, $code}++;
4273 $consumer->$add_modifier($method_name => $code);
4274 }
4275 }
4276 0 }
4277 return;
4278 }
4279 0 ▶ 
Subroutine _append_roles: not called CC=3 SCAR=24.8
4280 0 sub _append_roles {
4281 my($self, $role, $metaclass_or_role) = @_;
4282 0  
4283 0 my $roles = $metaclass_or_role->{roles};
4284 0 ▶ foreach my $r($role, @{$role->get_roles}){
Branch: 1 branch
BranchTrueFalseTotal
unless ($metaclass_or_role->does_role($r)) 0 0 0
4285 0 if(!$metaclass_or_role->does_role($r)){
4286 push @{$roles}, $r;
4287 }
4288 0 }
4289 return;
4290 }
4291 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=4.7
4292 BEGIN{ # lib/Mouse/Meta/Role/Composite.pm
4293 2 ▶package Mouse::Meta::Role::Composite;
Subroutine BEGIN: called CC=1 SCAR=0.0
4294 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
4295 2 ▶use Mouse::Util; # enables strict and warnings
Subroutine BEGIN: called CC=1 SCAR=0.0
4296 2 ▶use Mouse::Meta::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4297 2 use Mouse::Meta::Role::Application;
4298 our @ISA = qw(Mouse::Meta::Role);
4299  
4300 # FIXME: Mouse::Meta::Role::Composite does things in different way from Moose's
4301 # Moose: creates a new class for the consumer, and applies roles to it.
4302 # Mouse: creates a composite role and apply roles to the role,
4303 # and then applies it to the consumer.
4304 0 ▶ 
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
4305 0 sub new {
4306 0 my $class = shift;
4307 0 my $args = $class->Mouse::Object::BUILDARGS(@_);
4308 0 my $roles = delete $args->{roles};
4309 0 my $self = $class->create_anon_role(%{$args});
4310 foreach my $role_spec(@{$roles}) {
4311 0 ▶ my($role, $args) = ref($role_spec) eq 'ARRAY'
Branch: 1 branch
BranchTrueFalseTotal
ref $role_spec eq 'ARRAY' ? : 0 0 0
4312 ? @{$role_spec}
4313 0 : ($role_spec, {});
4314 $role->apply($self, %{$args});
4315 0 }
4316 return $self;
4317 }
4318 0 ▶ 
Subroutine get_method_list: not called CC=1 SCAR=6.9
Pod undocumented
4319 0 sub get_method_list {
4320 0 my($self) = @_;
4321 0 return grep { ! $self->{conflicting_methods}{$_} }
4322 keys %{ $self->{methods} };
4323 }
4324 0 ▶ 
Subroutine add_method: not called CC=6 SCAR=37.4
Pod undocumented
4325 0 sub add_method {
4326 my($self, $method_name, $code, $role) = @_;
4327 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (($self->{"methods"}{$method_name} || 0) == $code) 0 0 0
Condition0%0/2
$self->{'methods'}{$method_name} || 0
l!l
00
MC/DC0%0/1
$self->{'methods'}{$method_name} || 0
$self->{'methods'}{$method_name}
Truth table0%0/2
A
A= $self->{'methods'}{$method_name}
Aresult
11
00
4328 if( ($self->{methods}{$method_name} || 0) == $code){
4329 0 # This role already has the same method.
4330 return;
4331 }
4332 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($method_name eq 'meta') { } 0 0 0
4333 0 if($method_name eq 'meta'){
4334 $self->SUPER::add_method($method_name => $code);
4335 }
4336 else{
4337 0 ▶ # no need to add a subroutine to the stash
Condition0%0/2
$self->{"composed_roles_by_method"}{$method_name} ||= []
l!l
00
MC/DC0%0/1
$self->{"composed_roles_by_method"}{$method_name} ||= []
$self->{"composed_roles_by_method"}{$method_name}
Truth table0%0/2
A
A= $self->{"composed_roles_by_method"}{$method_name}
Aresult
11
00
4338 0 my $roles = $self->{composed_roles_by_method}{$method_name} ||= [];
4339 0 ▶ push @{$roles}, $role;
Branch: 1 branch
BranchTrueFalseTotal
if (@{$roles;} > 1) 0 0 0
4340 0 if(@{$roles} > 1){
4341 $self->{conflicting_methods}{$method_name}++;
4342 0 }
4343 $self->{methods}{$method_name} = $code;
4344 0 }
4345 return;
4346 }
4347 0 ▶ 
Subroutine get_method_body: not called CC=1 SCAR=6.9
Pod undocumented
4348 0 sub get_method_body {
4349 0 my($self, $method_name) = @_;
4350 return $self->{methods}{$method_name};
4351 }
4352 0 ▶ 
Subroutine has_method: not called CC=1 SCAR=6.9
Pod undocumented
4353 sub has_method {
4354 0 # my($self, $method_name) = @_;
4355 return 0; # to fool apply_methods() in combine()
4356 }
4357 0 ▶ 
Subroutine has_attribute: not called CC=1 SCAR=6.9
Pod undocumented
4358 sub has_attribute {
4359 0 # my($self, $method_name) = @_;
4360 return 0; # to fool appply_attributes() in combine()
4361 }
4362 0 ▶ 
Subroutine has_override_method_modifier: not called CC=1 SCAR=6.9
Pod undocumented
4363 sub has_override_method_modifier {
4364 0 # my($self, $method_name) = @_;
4365 return 0; # to fool apply_modifiers() in combine()
4366 }
4367 0 ▶ 
Subroutine add_attribute: not called CC=4 SCAR=30.0
Pod undocumented
4368 0 sub add_attribute {
4369 0 my $self = shift;
4370 0 ▶ my $attr_name = shift;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 0 0
4371 my $spec = (@_ == 1 ? $_[0] : {@_});
4372 0  
4373 0 ▶ my $existing = $self->{attributes}{$attr_name};
Branch: 1 branch
BranchTrueFalseTotal
if ($existing and $existing != $spec) 0 0 0
Condition0%0/3
$existing and $existing != $spec
!ll&&!rl&&r
000
MC/DC0%0/2
$existing and $existing != $spec
$existing $existing != $spec
Truth table0%0/3
A and B
A= $existingB= $existing != $spec
ABresult
0X0
100
111
4374 0 if($existing && $existing != $spec){
4375 $self->throw_error("We have encountered an attribute conflict with '$attr_name' "
4376 . "during composition. This is fatal error and cannot be disambiguated.");
4377 0 }
4378 0 $self->SUPER::add_attribute($attr_name, $spec);
4379 return;
4380 }
4381 0 ▶ 
Subroutine add_override_method_modifier: not called CC=3 SCAR=24.8
Pod undocumented
4382 0 sub add_override_method_modifier {
4383 my($self, $method_name, $code) = @_;
4384 0  
4385 0 ▶ my $existing = $self->{override_method_modifiers}{$method_name};
Branch: 1 branch
BranchTrueFalseTotal
if ($existing and $existing != $code) 0 0 0
Condition0%0/3
$existing and $existing != $code
!ll&&!rl&&r
000
MC/DC0%0/2
$existing and $existing != $code
$existing $existing != $code
Truth table0%0/3
A and B
A= $existingB= $existing != $code
ABresult
0X0
100
111
4386 0 if($existing && $existing != $code){
4387 $self->throw_error( "We have encountered an 'override' method conflict with '$method_name' during "
4388 . "composition (Two 'override' methods of the same name encountered). "
4389 . "This is fatal error.")
4390 0 }
4391 0 $self->SUPER::add_override_method_modifier($method_name, $code);
4392 return;
4393 }
4394 0 ▶ 
Subroutine apply: not called CC=1 SCAR=6.9
Pod undocumented
4395 0 sub apply {
4396 0 my $self = shift;
4397 my $consumer = shift;
4398 0  
4399 0 Mouse::Meta::Role::Application::RoleSummation->new(@_)->apply($self, $consumer);
4400 return;
4401 }
4402  
4403 2 package Mouse::Meta::Role::Application::RoleSummation;
4404 our @ISA = qw(Mouse::Meta::Role::Application);
4405 0 ▶ 
Subroutine apply_methods: not called CC=9 SCAR=45.0
4406 0 sub apply_methods {
4407 my($self, $role, $consumer, @extra) = @_;
4408 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (exists $role->{"conflicting_methods"}) 0 0 0
4409 0 if(exists $role->{conflicting_methods}){
4410 my $consumer_class_name = $consumer->name;
4411 0  
4412 0 my @conflicting = grep{ !$consumer_class_name->can($_) }
4413 keys %{ $role->{conflicting_methods} };
4414 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (@conflicting) 0 0 0
4415 0 ▶ if(@conflicting) {
Branch: 1 branch
BranchTrueFalseTotal
@conflicting == 1 ? : 0 0 0
4416 my $method_name_conflict = (@conflicting == 1
4417 ? 'a method name conflict'
4418 : 'method name conflicts');
4419 0  
4420 my %seen;
4421 0 my $roles = Mouse::Util::quoted_english_list(
4422 0 grep{ !$seen{$_}++ } # uniq
4423 0 map { $_->name }
4424 0 map { @{$_} }
4425 @{ $role->{composed_roles_by_method} }{@conflicting}
4426 );
4427 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
@conflicting > 1 ? : 0 0 0
4428 $self->throw_error(sprintf
4429 q{Due to %s in roles %s,}
4430 . q{ the method%s %s must be implemented or excluded by '%s'},
4431 $method_name_conflict,
4432 $roles,
4433 (@conflicting > 1 ? 's' : ''),
4434 Mouse::Util::quoted_english_list(@conflicting),
4435 $consumer_class_name);
4436 }
4437  
4438 0 ▶ my @changed_in_v2_0_0 = grep {
Condition0%0/3
$consumer_class_name->can($_) && !$consumer->has_method($_)
!ll&&!rl&&r
000
MC/DC0%0/2
$consumer_class_name->can($_) && !$consumer->has_method($_)
$consumer_class_name->can($_) !$consumer->has_method($_)
Truth table0%0/3
A && not(B)
A= $consumer_class_name->can($_)B= !$consumer->has_method($_)
ABresult
0X0
100
111
4439 0 $consumer_class_name->can($_) && ! $consumer->has_method($_)
4440 0 ▶ } keys %{ $role->{conflicting_methods} };
Branch: 1 branch
BranchTrueFalseTotal
if (@changed_in_v2_0_0) 0 0 0
4441 0 ▶ if (@changed_in_v2_0_0) {
Branch: 1 branch
BranchTrueFalseTotal
@changed_in_v2_0_0 == 1 ? : 0 0 0
4442 my $method_name_conflict = (@changed_in_v2_0_0 == 1
4443 ? 'a method name conflict'
4444 : 'method name conflicts');
4445 0  
4446 my %seen;
4447 0 my $roles = Mouse::Util::quoted_english_list(
4448 0 grep{ !$seen{$_}++ } # uniq
4449 0 map { $_->name }
4450 0 map { @{$_} }
4451 @{ $role->{composed_roles_by_method} }{@changed_in_v2_0_0}
4452 );
4453 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
@changed_in_v2_0_0 > 1 ? : 0 0 0
4454 Carp::cluck(sprintf
4455 q{Due to %s in roles %s,}
4456 . q{ the behavior of method%s %s might be incompatible with Moose}
4457 . q{, check out %s},
4458 $method_name_conflict,
4459 $roles,
4460 (@changed_in_v2_0_0 > 1 ? 's' : ''),
4461 Mouse::Util::quoted_english_list(@changed_in_v2_0_0),
4462 $consumer_class_name);
4463 }
4464 }
4465 0  
4466 0 $self->SUPER::apply_methods($role, $consumer, @extra);
4467 return;
4468 }
4469  
4470 package Mouse::Meta::Role::Composite;
4471 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
4472 BEGIN{ # lib/Mouse/Meta/Role/Method.pm
4473 2 ▶package Mouse::Meta::Role::Method;
Subroutine BEGIN: called CC=1 SCAR=0.0
4474 use Mouse::Util; # enables strict and warnings
4475 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
4476 2 use Mouse::Meta::Method;
4477 our @ISA = qw(Mouse::Meta::Method);
4478 0 ▶ 
Subroutine _new: not called CC=2 SCAR=17.9
4479 0 sub _new{
4480 0 my($class, %args) = @_;
4481 my $self = bless \%args, $class;
4482 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($class ne __PACKAGE__) 0 0 0
4483 0 if($class ne __PACKAGE__){
4484 $self->meta->_initialize_object($self, \%args);
4485 0 }
4486 return $self;
4487 }
4488  
4489 }
4490 BEGIN{ # lib/Mouse/Object.pm
4491 2 ▶package Mouse::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
4492 use Mouse::Util qw(does dump meta); # enables strict and warnings
4493 # all the stuff are defined in XS or PP
4494 0 ▶ 
Subroutine DOES: not called CC=2 SCAR=17.9
Pod undocumented
4495 0 sub DOES {
4496 0 ▶ my($self, $class_or_role_name) = @_;
Condition0%0/3
$self->isa($class_or_role_name) || $self->does($class_or_role_name)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->isa($class_or_role_name) || $self->does($class_or_role_name)
$self->isa($class_or_role_name) $self->does($class_or_role_name)
Truth table0%0/3
A || B
A= $self->isa($class_or_role_name)B= $self->does($class_or_role_name)
ABresult
1X1
011
000
4497 return $self->isa($class_or_role_name) || $self->does($class_or_role_name);
4498 }
4499  
4500 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
4501 BEGIN{ # lib/Mouse/Role.pm
4502 2 ▶package Mouse::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4503 use Mouse::Exporter; # enables strict and warnings
4504 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
4505 use version; our $VERSION = version->declare('v2.6.2');
4506 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
4507 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
4508 use Scalar::Util ();
4509 2 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
4510 use Mouse ();
4511 2  
4512 Mouse::Exporter->setup_import_methods(
4513 as_is => [qw(
4514 extends with
4515 has
4516 before after around
4517 override super
4518 augment inner
4519  
4520 requires excludes
4521 ),
4522 \&Scalar::Util::blessed,
4523 \&Carp::confess,
4524 ],
4525 );
4526  
4527 0 ▶ 
Subroutine extends: not called CC=1 SCAR=6.9
Pod undocumented
4528 0 sub extends {
4529 Carp::croak "Roles do not support 'extends'";
4530 }
4531 0 ▶ 
Subroutine with: not called CC=1 SCAR=6.9
Pod undocumented
4532 0 sub with {
4533 0 Mouse::Util::apply_all_roles(scalar(caller), @_);
4534 return;
4535 }
4536 0 ▶ 
Subroutine has: not called CC=4 SCAR=30.0
Pod undocumented
4537 0 sub has {
4538 0 my $meta = Mouse::Meta::Role->initialize(scalar caller);
4539 my $name = shift;
4540 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 0 0 0
4541 $meta->throw_error(q{Usage: has 'name' => ( key => value, ... )})
4542 if @_ % 2; # odd number of arguments
4543 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
ref $name ? : 0 0 0
4544 0 for my $n(ref($name) ? @{$name} : $name){
4545 $meta->add_attribute($n => @_);
4546 0 }
4547 return;
4548 }
4549 0 ▶ 
Subroutine before: not called CC=2 SCAR=17.9
Pod undocumented
4550 0 sub before {
4551 0 my $meta = Mouse::Meta::Role->initialize(scalar caller);
4552 0 my $code = pop;
4553 0 for my $name($meta->_collect_methods(@_)) {
4554 $meta->add_before_method_modifier($name => $code);
4555 0 }
4556 return;
4557 }
4558 0 ▶ 
Subroutine after: not called CC=2 SCAR=17.9
Pod undocumented
4559 0 sub after {
4560 0 my $meta = Mouse::Meta::Role->initialize(scalar caller);
4561 0 my $code = pop;
4562 0 for my $name($meta->_collect_methods(@_)) {
4563 $meta->add_after_method_modifier($name => $code);
4564 0 }
4565 return;
4566 }
4567 0 ▶ 
Subroutine around: not called CC=2 SCAR=17.9
Pod undocumented
4568 0 sub around {
4569 0 my $meta = Mouse::Meta::Role->initialize(scalar caller);
4570 0 my $code = pop;
4571 0 for my $name($meta->_collect_methods(@_)) {
4572 $meta->add_around_method_modifier($name => $code);
4573 0 }
4574 return;
4575 }
4576  
4577 0 ▶ 
Subroutine super: not called CC=2 SCAR=17.9
Pod undocumented
4578 0 ▶sub super {
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Mouse::SUPER_BODY 0 0 0
4579 0 return if !defined $Mouse::SUPER_BODY;
4580 $Mouse::SUPER_BODY->(@Mouse::SUPER_ARGS);
4581 }
4582 0 ▶ 
Subroutine override: not called CC=1 SCAR=6.9
Pod undocumented
4583 sub override {
4584 0 # my($name, $code) = @_;
4585 0 Mouse::Meta::Role->initialize(scalar caller)->add_override_method_modifier(@_);
4586 return;
4587 }
4588  
4589 0 ▶# We keep the same errors messages as Moose::Role emits, here.
Subroutine inner: not called CC=1 SCAR=6.9
Pod undocumented
4590 0 sub inner {
4591 Carp::croak "Roles cannot support 'inner'";
4592 }
4593 0 ▶ 
Subroutine augment: not called CC=1 SCAR=6.9
Pod undocumented
4594 0 sub augment {
4595 Carp::croak "Roles cannot support 'augment'";
4596 }
4597 0 ▶ 
Subroutine requires: not called CC=2 SCAR=17.9
Pod documented
4598 0 sub requires {
4599 0 ▶ my $meta = Mouse::Meta::Role->initialize(scalar caller);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
4600 0 $meta->throw_error("Must specify at least one method") unless @_;
4601 0 $meta->add_required_methods(@_);
4602 return;
4603 }
4604 0 ▶ 
Subroutine excludes: not called CC=1 SCAR=6.9
Pod documented
4605 0 sub excludes {
4606 Mouse::Util::not_supported();
4607 }
4608 0 ▶ 
Subroutine init_meta: not called CC=5 SCAR=34.0
Pod undocumented
4609 0 sub init_meta{
4610 0 shift;
4611 my %args = @_;
4612  
4613 0 ▶ my $class = $args{for_class}
Branch: 1 branch
BranchTrueFalseTotal
my $class = $args{"for_class"} or Carp::confess("Cannot call init_meta without specifying a for_class") 0 0 0
4614 or Carp::confess("Cannot call init_meta without specifying a for_class");
4615 0 ▶ 
Condition0%0/2
$args{'metaclass'} || 'Mouse::Meta::Role'
l!l
00
MC/DC0%0/1
$args{'metaclass'} || 'Mouse::Meta::Role'
$args{'metaclass'}
Truth table0%0/2
A
A= $args{'metaclass'}
Aresult
11
00
4616 my $metaclass = $args{metaclass} || 'Mouse::Meta::Role';
4617 0  
4618 0 my $meta = $metaclass->initialize($class);
4619 my $filename = Mouse::Util::module_notional_filename($meta->name);
4620 0 ▶ $INC{$filename} = '(set by Mouse)'
Branch: 1 branch
BranchTrueFalseTotal
unless exists $INC{$filename} 0 0 0
4621 unless exists $INC{$filename};
4622 0 ▶ 
Subroutine __ANON__: not called CC=2 SCAR=17.9
4623 0 ▶ $meta->add_method(meta => sub{
Condition0%0/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
4624 0 $metaclass->initialize(ref($_[0]) || $_[0]);
4625 });
4626  
4627 0 ▶ # make a role type for each Mouse role
Branch: 1 branch
BranchTrueFalseTotal
unless Mouse::Util::TypeConstraints::find_type_constraint($class) 0 0 0
4628 Mouse::Util::TypeConstraints::role_type($class)
4629 unless Mouse::Util::TypeConstraints::find_type_constraint($class);
4630 0  
4631 return $meta;
4632 }
4633  
4634 }
4635 BEGIN{ # lib/Mouse/Util/MetaRole.pm
4636 2 ▶package Mouse::Util::MetaRole;
Subroutine BEGIN: called CC=1 SCAR=0.0
4637 2 ▶use Mouse::Util; # enables strict and warnings
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
4638 use Scalar::Util ();
4639 0 ▶ 
Subroutine apply_metaclass_roles: not called CC=1 SCAR=6.9
Pod undocumented
4640 0 sub apply_metaclass_roles {
4641 0 my %args = @_;
4642 _fixup_old_style_args(\%args);
4643 0  
4644 return apply_metaroles(%args);
4645 }
4646 0 ▶ 
Subroutine apply_metaroles: not called CC=4 SCAR=30.0
Pod documented
4647 0 sub apply_metaroles {
4648 my %args = @_;
4649  
4650 my $for = Scalar::Util::blessed($args{for})
4651 0 ▶ ? $args{for}
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($args{'for'}) ? : 0 0 0
4652 : Mouse::Util::get_metaclass_by_name( $args{for} );
4653 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless ($for) 0 0 0
4654 0 if(!$for){
4655 Carp::confess("You must pass an initialized class, but '$args{for}' has no metaclass");
4656 }
4657 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (Mouse::Util::is_a_metarole($for)) { } 0 0 0
4658 0 if ( Mouse::Util::is_a_metarole($for) ) {
4659 return _make_new_metaclass( $for, $args{role_metaroles}, 'role' );
4660 }
4661 0 else {
4662 return _make_new_metaclass( $for, $args{class_metaroles}, 'class' );
4663 }
4664 }
4665 0 ▶ 
Subroutine _make_new_metaclass: not called CC=6 SCAR=37.4
4666 0 sub _make_new_metaclass {
4667 my($for, $roles, $primary) = @_;
4668 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$roles;} 0 0 0
4669 return $for unless keys %{$roles};
4670  
4671 0 ▶ my $new_metaclass = exists($roles->{$primary})
Branch: 1 branch
BranchTrueFalseTotal
exists $roles->{$primary} ? : 0 0 0
4672 ? _make_new_class( ref $for, $roles->{$primary} ) # new class with traits
4673 : ref $for;
4674 0  
4675 my %classes;
4676 0  
4677 0 for my $key ( grep { $_ ne $primary } keys %{$roles} ) {
4678 0 ▶ my $metaclass;
Condition0%0/6
$for->can($metaclass = $key . '_metaclass') || $for->can($metaclass = $key . '_class') || $for->throw_error("Unknown metaclass '${key}'")
l!l&&r!l&&!r
000
$for->can($metaclass = $key . '_metaclass') or $for->can($metaclass = $key . '_class')
l!l&&r!l&&!r
000
MC/DC0%0/3
$for->can($metaclass = $key . '_metaclass') || $for->can($metaclass = $key . '_class') || $for->throw_error("Unknown metaclass '${key}'")
$for->can($metaclass = $key . '_metaclass') $for->can($metaclass = $key . '_class') $for->throw_error("Unknown metaclass '${key}'")
Truth table0%0/4
A or B || C
A= $for->can($metaclass = $key . '_metaclass')B= $for->can($metaclass = $key . '_class')C= $for->throw_error("Unknown metaclass '${key}'")
ABCresult
1XX1
01X1
0011
0000
4679 my $attr = $for->can($metaclass = ($key . '_metaclass'))
4680 || $for->can($metaclass = ($key . '_class'))
4681 || $for->throw_error("Unknown metaclass '$key'");
4682  
4683 0 $classes{ $metaclass }
4684 = _make_new_class( $for->$attr(), $roles->{$key} );
4685 }
4686 0  
4687 return $new_metaclass->reinitialize( $for, %classes );
4688 }
4689  
4690 0 ▶ 
Subroutine _fixup_old_style_args: not called CC=10 SCAR=47.0
4691 0 sub _fixup_old_style_args {
4692 my $args = shift;
4693 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"class_metaroles"} or $args->{"roles_metaroles"} 0 0 0
Condition0%0/3
$args->{"class_metaroles"} or $args->{"roles_metaroles"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{"class_metaroles"} or $args->{"roles_metaroles"}
$args->{"class_metaroles"} $args->{"roles_metaroles"}
Truth table0%0/3
A or B
A= $args->{"class_metaroles"}B= $args->{"roles_metaroles"}
ABresult
1X1
011
000
4694 return if $args->{class_metaroles} || $args->{roles_metaroles};
4695  
4696 0 ▶ $args->{for} = delete $args->{for_class}
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"for_class"} 0 0 0
4697 if exists $args->{for_class};
4698 0  
4699 my @old_keys = qw(
4700 attribute_metaclass_roles
4701 method_metaclass_roles
4702 wrapped_method_metaclass_roles
4703 instance_metaclass_roles
4704 constructor_class_roles
4705 destructor_class_roles
4706 error_class_roles
4707  
4708 application_to_class_class_roles
4709 application_to_role_class_roles
4710 application_to_instance_class_roles
4711 application_role_summation_class_roles
4712 );
4713  
4714 my $for = Scalar::Util::blessed($args->{for})
4715 0 ▶ ? $args->{for}
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($args->{'for'}) ? : 0 0 0
4716 : Mouse::Util::get_metaclass_by_name( $args->{for} );
4717 0  
4718 0 ▶ my $top_key;
Branch: 1 branch
BranchTrueFalseTotal
if (Mouse::Util::is_a_metaclass($for)) { } 0 0 0
4719 0 if( Mouse::Util::is_a_metaclass($for) ){
4720 $top_key = 'class_metaroles';
4721  
4722 0 ▶ $args->{class_metaroles}{class} = delete $args->{metaclass_roles}
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"metaclass_roles"} 0 0 0
4723 if exists $args->{metaclass_roles};
4724 }
4725 0 else {
4726 $top_key = 'role_metaroles';
4727  
4728 0 ▶ $args->{role_metaroles}{role} = delete $args->{metaclass_roles}
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"metaclass_roles"} 0 0 0
4729 if exists $args->{metaclass_roles};
4730 }
4731 0  
4732 0 for my $old_key (@old_keys) {
4733 my ($new_key) = $old_key =~ /^(.+)_(?:class|metaclass)_roles$/;
4734  
4735 0 ▶ $args->{$top_key}{$new_key} = delete $args->{$old_key}
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{$old_key} 0 0 0
4736 if exists $args->{$old_key};
4737 }
4738 0  
4739 return;
4740 }
4741  
4742 0 ▶ 
Subroutine apply_base_class_roles: not called CC=2 SCAR=17.9
Pod documented
4743 0 sub apply_base_class_roles {
4744 my %options = @_;
4745 0  
4746 my $for = $options{for_class};
4747 0  
4748 my $meta = Mouse::Util::class_of($for);
4749  
4750 my $new_base = _make_new_class(
4751 $for,
4752 0 $options{roles},
4753 [ $meta->superclasses() ],
4754 );
4755 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $new_base ne $meta->name 0 0 0
4756 $meta->superclasses($new_base)
4757 0 if $new_base ne $meta->name();
4758 return;
4759 }
4760 0 ▶ 
Subroutine _make_new_class: not called CC=6 SCAR=37.4
4761 0 sub _make_new_class {
4762 my($existing_class, $roles, $superclasses) = @_;
4763 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless ($superclasses) 0 0 0
4764 0 ▶ if(!$superclasses){
Branch: 1 branch
BranchTrueFalseTotal
unless $roles 0 0 0
4765 return $existing_class if !$roles;
4766 0  
4767 my $meta = Mouse::Meta::Class->initialize($existing_class);
4768  
4769 0 ▶ return $existing_class
Branch: 1 branch
BranchTrueFalseTotal
unless grep {not ref $_ || $meta->does_role($_);} @{$roles;} 0 0 0
Condition0%0/3
ref $_ || $meta->does_role($_)
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_ || $meta->does_role($_)
ref $_ $meta->does_role($_)
Truth table0%0/3
A || B
A= ref $_B= $meta->does_role($_)
ABresult
1X1
011
000
4770 if !grep { !ref($_) && !$meta->does_role($_) } @{$roles};
4771 }
4772 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
$superclasses ? : 0 0 0
4773 return Mouse::Meta::Class->create_anon_class(
4774 superclasses => $superclasses ? $superclasses : [$existing_class],
4775 roles => $roles,
4776 cache => 1,
4777 )->name();
4778 }
4779  
4780 }
4781 END_OF_TINY
4782 2 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 2 2
4783 } # unless Mouse.pm is loaded
4784 package Mouse::Tiny;
4785  
4786 4 ▶use version; our $VERSION = version->declare('v2.6.2');
Subroutine BEGIN: called CC=1 SCAR=0.0
4787  
4788 2 Mouse::Exporter->setup_import_methods(also => 'Mouse');
4789  
4790 2 1;
« blib/lib/Mouse/PurePerl.pm ↑ Summary blib/lib/Mouse/Util/MetaRole.pm »