/usr/local/lib/perl5/site_perl/5.44.0/Moo/Role.pm

filter: Statementstmt 34.6% 82 / 237 Branchbran 10.5% 8 / 76 Conditioncond 14.7% 18 / 122 MC/DCmcdc 0.0% 0 / 64 Subroutinesub 58.5% 24 / 41 Podpod 60.0% 3 / 5 totaltotal 24.7% 135 / 545 CC 91 SCAR 41.9
CC
91
Cov
25%
_inhale_if_moose
236.2
_handle_constructor
121.9
_gen_apply_defaults_for
90.5
CRAP 65.7
« /usr/local/lib/perl5/5.44.0/CPAN/Meta/Prereqs.pm ↑ Summary /usr/local/lib/perl5/5.44.0/x86_64-linux/Config_heavy.pl »
1 package Moo::Role;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use Moo::_Utils qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
6 _check_tracked
7 _getglob
8 _getstash
9 _install_coderef
10 _install_modifier
11 _install_tracked
12 _load_module
13 _name_coderef
14 _set_loaded
15 _unimport_coderefs
16 5 );
17 5 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use Role::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶BEGIN { our @ISA = qw(Role::Tiny) }
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 our @CARP_NOT = qw(
22 Method::Generate::Accessor
23 Method::Generate::Constructor
24 Moo::sification
25 Moo::_Utils
26 Role::Tiny
27 );
28 }
29  
30 5 our $VERSION = '2.005005';
31 5 $VERSION =~ tr/_//d;
32  
33 5 require Moo::sification;
34 5 Moo::sification->import;
35  
36 5 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
37 5 *INFO = \%Role::Tiny::INFO;
38 5 *APPLIED_TO = \%Role::Tiny::APPLIED_TO;
39 5 *COMPOSED = \%Role::Tiny::COMPOSED;
40 5 *ON_ROLE_CREATE = \@Role::Tiny::ON_ROLE_CREATE;
41 }
42  
43 5 our %INFO;
44 5 our %APPLIED_TO;
45 5 our %APPLY_DEFAULTS;
46 5 our %COMPOSED;
47 5 our @ON_ROLE_CREATE;
48  
49 5 ▶sub import {
Subroutine import: called CC=3 SCAR=12.7
50 5 my $target = caller;
51 5 ▶ if ($Moo::MAKERS{$target} and $Moo::MAKERS{$target}{is_class}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Moo::MAKERS{$target} and $Moo::MAKERS{$target}{"is_class"}) 0 5 5
Condition33%1/3
$Moo::MAKERS{$target} and $Moo::MAKERS{$target}{"is_class"}
!ll&&!rl&&r
500
MC/DC0%0/2
$Moo::MAKERS{$target} and $Moo::MAKERS{$target}{"is_class"}
$Moo::MAKERS{$target} $Moo::MAKERS{$target}{"is_class"}
Truth table33%1/3
A and B
A= $Moo::MAKERS{$target}B= $Moo::MAKERS{$target}{"is_class"}
ABresult
0X0
100
111
52 0 croak "Cannot import Moo::Role into a Moo class";
53 }
54 5 _set_loaded(caller);
55 5 goto &Role::Tiny::import;
56 }
57  
58 0 ▶sub _accessor_maker_for {
Subroutine _accessor_maker_for: not called CC=2 SCAR=17.9
59 0 my ($class, $target) = @_;
60 0 ▶ ($INFO{$target}{accessor_maker} ||= do {
Condition0%0/3
$Moo::Role::INFO{$target}{"accessor_maker"} ||= do { require Method::Generate::Accessor; "Method::Generate::Accessor"->new }
l!l&&r!l&&!r
000
MC/DC0%0/2
$Moo::Role::INFO{$target}{"accessor_maker"} ||= do { require Method::Generate::Accessor; "Method::Generate::Accessor"->new }
$Moo::Role::INFO{$target}{"accessor_maker"} do { require Method::Generate::Accessor; "Method::Generate::Accessor"->new }
Truth table0%0/3
A ||= B
A= $Moo::Role::INFO{$target}{"accessor_maker"}B= do { require Method::Generate::Accessor; "Method::Generate::Accessor"->new }
ABresult
1X1
011
000
61 0 require Method::Generate::Accessor;
62 0 Method::Generate::Accessor->new
63 });
64 }
65  
66 5 ▶sub _install_subs {
Subroutine _install_subs: called CC=2 SCAR=6.9
67 5 my ($me, $target) = @_;
68 5 my %install = $me->_gen_subs($target);
69 _install_tracked $target => $_ => $install{$_}
70 5 for sort keys %install;
71 5 *{_getglob("${target}::meta")} = $me->can('meta');
72 5 return;
73 }
74  
75 15 ▶sub _require_module {
Subroutine _require_module: called CC=1 SCAR=0.0
76 15 _load_module($_[1]);
77 }
78  
79 5 ▶sub _gen_subs {
Subroutine _gen_subs: called CC=1 SCAR=5.0
80 5 my ($me, $target) = @_;
81 return (
82 0 ▶ has => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
Subroutine has: not called CC=6 SCAR=37.4
83 0 my $name_proto = shift;
84 0 ▶ my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto;
Branch: 2 branches
BranchTrueFalseTotal
ref $name_proto eq 'ARRAY' ? : 0 0 0
ref $name_proto eq 'ARRAY' ? : 0 0 0
85 0 ▶ if (@_ % 2 != 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ % 2 != 0) 0 0 0
if (@_ % 2 != 0) 0 0 0
86 0 croak("Invalid options for " . join(', ', map "'$_'", @name_proto)
87 . " attribute(s): even number of arguments expected, got " . scalar @_)
88 }
89 0 my %spec = @_;
90 0 foreach my $name (@name_proto) {
91 0 ▶ my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec;
Branch: 2 branches
BranchTrueFalseTotal
@name_proto > 1 ? : 0 0 0
@name_proto > 1 ? : 0 0 0
92 0 $me->_accessor_maker_for($target)
93 ->generate_method($target, $name, $spec_ref);
94 0 ▶ push @{$INFO{$target}{attributes}||=[]}, $name, $spec_ref;
Condition0%0/4
$Moo::Role::INFO{$target}{"attributes"} ||= []
l!l
00
$Moo::Role::INFO{$target}{"attributes"} ||= []
l!l
00
MC/DC0%0/1
$Moo::Role::INFO{$target}{"attributes"} ||= []
$Moo::Role::INFO{$target}{"attributes"}
MC/DC0%0/1
$Moo::Role::INFO{$target}{"attributes"} ||= []
$Moo::Role::INFO{$target}{"attributes"}
Truth table0%0/2
A
A= $Moo::Role::INFO{$target}{"attributes"}
Aresult
11
00
Truth table0%0/2
A
A= $Moo::Role::INFO{$target}{"attributes"}
Aresult
11
00
95 0 $me->_maybe_reset_handlemoose($target);
96 }
97 },
98 (map {
99 15 my $type = $_;
100 (
101 0 ▶ $type => sub {
Subroutine around: not called CC=2 SCAR=17.9
Subroutine after: not called CC=2 SCAR=17.9
102 0 ▶ push @{$INFO{$target}{modifiers}||=[]}, [ $type => @_ ];
Condition0%0/4
$Moo::Role::INFO{$target}{"modifiers"} ||= []
l!l
00
$Moo::Role::INFO{$target}{"modifiers"} ||= []
l!l
00
MC/DC0%0/1
$Moo::Role::INFO{$target}{"modifiers"} ||= []
$Moo::Role::INFO{$target}{"modifiers"}
MC/DC0%0/1
$Moo::Role::INFO{$target}{"modifiers"} ||= []
$Moo::Role::INFO{$target}{"modifiers"}
Truth table0%0/2
A
A= $Moo::Role::INFO{$target}{"modifiers"}
Aresult
11
00
Truth table0%0/2
A
A= $Moo::Role::INFO{$target}{"modifiers"}
Aresult
11
00
103 0 $me->_maybe_reset_handlemoose($target);
104 },
105 )
106 15 } qw(before after around)),
107 5 ▶ requires => sub {
Subroutine requires: called CC=2 SCAR=7.1
108 5 ▶ push @{$INFO{$target}{requires}||=[]}, @_;
Condition50%1/2
$Moo::Role::INFO{$target}{"requires"} ||= []
l!l
05
MC/DC0%0/1
$Moo::Role::INFO{$target}{"requires"} ||= []
$Moo::Role::INFO{$target}{"requires"}
Truth table50%1/2
A
A= $Moo::Role::INFO{$target}{"requires"}
Aresult
11
00
109 5 $me->_maybe_reset_handlemoose($target);
110 },
111 0 ▶ with => sub {
Subroutine with: not called CC=1 SCAR=6.9
112 0 $me->apply_roles_to_package($target, @_);
113 0 $me->_maybe_reset_handlemoose($target);
114 },
115 5 );
116 }
117  
118 5 ▶push @ON_ROLE_CREATE, sub {
Subroutine __ANON__: called CC=3 SCAR=14.2
119 5 my $target = shift;
120 5 ▶ if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"Moo/HandleMoose.pm"} and not $Moo::sification::disabled) 0 5 5
Condition33%1/3
$INC{"Moo/HandleMoose.pm"} and not $Moo::sification::disabled
!ll&&!rl&&r
500
MC/DC0%0/2
$INC{"Moo/HandleMoose.pm"} and not $Moo::sification::disabled
$INC{"Moo/HandleMoose.pm"} not $Moo::sification::disabled
Truth table33%1/3
A and not(B)
A= $INC{"Moo/HandleMoose.pm"}B= not $Moo::sification::disabled
ABresult
0X0
100
111
121 0 Moo::HandleMoose::inject_fake_metaclass_for($target);
122 }
123 5 };
124  
125 # duplicate from Moo::Object
126 0 ▶sub meta {
Subroutine meta: not called CC=2 SCAR=17.9
Pod undocumented
127 0 require Moo::HandleMoose::FakeMetaClass;
128 0 ▶ my $class = ref($_[0])||$_[0];
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
129 0 bless({ name => $class }, 'Moo::HandleMoose::FakeMetaClass');
130 }
131  
132 0 ▶sub unimport {
Subroutine unimport: not called CC=1 SCAR=6.9
133 0 my $target = caller;
134 0 _unimport_coderefs($target);
135 }
136  
137 5 ▶sub _maybe_reset_handlemoose {
Subroutine _maybe_reset_handlemoose: called CC=3 SCAR=14.2
138 5 my ($class, $target) = @_;
139 5 ▶ if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"Moo/HandleMoose.pm"} and not $Moo::sification::disabled) 0 5 5
Condition33%1/3
$INC{"Moo/HandleMoose.pm"} and not $Moo::sification::disabled
!ll&&!rl&&r
500
MC/DC0%0/2
$INC{"Moo/HandleMoose.pm"} and not $Moo::sification::disabled
$INC{"Moo/HandleMoose.pm"} not $Moo::sification::disabled
Truth table33%1/3
A and not(B)
A= $INC{"Moo/HandleMoose.pm"}B= not $Moo::sification::disabled
ABresult
0X0
100
111
140 0 Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target);
141 }
142 }
143  
144 10 ▶sub _non_methods {
Subroutine _non_methods: called CC=2 SCAR=6.9
145 10 my $self = shift;
146 10 my ($role) = @_;
147  
148 10 my $non_methods = $self->SUPER::_non_methods(@_);
149  
150 10 my $all_subs = $self->_all_subs($role);
151 $non_methods->{$_} = $all_subs->{$_}
152 10 for _check_tracked($role, [ keys %$all_subs ]);
153  
154 10 return $non_methods;
155 }
156  
157 35 ▶sub is_role {
Subroutine is_role: called CC=1 SCAR=0.0
Pod documented
158 35 my ($self, $role) = @_;
159 35 $self->_inhale_if_moose($role);
160 35 $self->SUPER::is_role($role);
161 }
162  
163 35 ▶sub _inhale_if_moose {
Subroutine _inhale_if_moose: called CC=19 SCAR=54.6
164 35 my ($self, $role) = @_;
165 35 my $meta;
166 35 ▶ if (!$self->SUPER::is_role($role)
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->SUPER::is_role($role) and ($INC{"Moose.pm"} and $meta = Class::MOP::class_of($role) and ref $meta ne "Moo::HandleMoose::FakeMetaClass" and $meta->isa("Moose::Meta::Role")) or "Mouse::Util"->can("find_meta") and $meta = Mouse::Util::find_meta($role) and $meta->isa("Mouse::Meta::Role")) 0 35 35
Condition38%8/21
not $self->SUPER::is_role($role) and ($INC{"Moose.pm"} and $meta = Class::MOP::class_of($role) and ref $meta ne "Moo::HandleMoose::FakeMetaClass" and $meta->isa("Moose::Meta::Role")) or "Mouse::Util"->can("find_meta") and $meta = Mouse::Util::find_meta($role) and $meta->isa("Mouse::Meta::Role")
l!l&&r!l&&!r
0035
not $self->SUPER::is_role($role) and ($INC{"Moose.pm"} and $meta = Class::MOP::class_of($role) and ref $meta ne "Moo::HandleMoose::FakeMetaClass" and $meta->isa("Moose::Meta::Role"))
!ll&&!rl&&r
15200
$INC{"Moose.pm"} and $meta = Class::MOP::class_of($role) and ref $meta ne "Moo::HandleMoose::FakeMetaClass" and $meta->isa("Moose::Meta::Role")
!ll&&!rl&&r
2000
$INC{"Moose.pm"} and $meta = Class::MOP::class_of($role) and ref $meta ne "Moo::HandleMoose::FakeMetaClass"
!ll&&!rl&&r
2000
$INC{"Moose.pm"} and $meta = Class::MOP::class_of($role)
!ll&&!rl&&r
2000
"Mouse::Util"->can("find_meta") and $meta = Mouse::Util::find_meta($role) and $meta->isa("Mouse::Meta::Role")
!ll&&!rl&&r
3500
"Mouse::Util"->can("find_meta") and $meta = Mouse::Util::find_meta($role)
!ll&&!rl&&r
3500
MC/DC0%0/8
not $self->SUPER::is_role($role) and ($INC{"Moose.pm"} and $meta = Class::MOP::class_of($role) and ref $meta ne "Moo::HandleMoose::FakeMetaClass" and $meta->isa("Moose::Meta::Role")) or "Mouse::Util"->can("find_meta") and $meta = Mouse::Util::find_meta($role) and $meta->isa("Mouse::Meta::Role")
not $self->SUPER::is_role($role) $INC{"Moose.pm"} $meta = Class::MOP::class_of($role) ref $meta ne "Moo::HandleMoose::FakeMetaClass" $meta->isa("Moose::Meta::Role") "Mouse::Util"->can("find_meta") $meta = Mouse::Util::find_meta($role) $meta->isa("Mouse::Meta::Role")
Truth table9%2/21
not(A) and B and C and D and E or F and G and H
A= not $self->SUPER::is_role($role)B= $INC{"Moose.pm"}C= $meta = Class::MOP::class_of($role)D= ref $meta ne "Moo::HandleMoose::FakeMetaClass"E= $meta->isa("Moose::Meta::Role")F= "Mouse::Util"->can("find_meta")G= $meta = Mouse::Util::find_meta($role)H= $meta->isa("Mouse::Meta::Role")
ABCDEFGHresult
11111XXX1
0XXXX1111
10XXX1111
110XX1111
1110X1111
111101111
0XXXX0XX0
0XXXX10X0
0XXXX1100
10XXX0XX0
10XXX10X0
10XXX1100
110XX0XX0
110XX10X0
110XX1100
1110X0XX0
1110X10X0
1110X1100
111100XX0
1111010X0
111101100
167 and (
168 $INC{"Moose.pm"}
169 and $meta = Class::MOP::class_of($role)
170 and ref $meta ne 'Moo::HandleMoose::FakeMetaClass'
171 and $meta->isa('Moose::Meta::Role')
172 )
173 or (
174 Mouse::Util->can('find_meta')
175 and $meta = Mouse::Util::find_meta($role)
176 and $meta->isa('Mouse::Meta::Role')
177 )
178 ) {
179 0 my $is_mouse = $meta->isa('Mouse::Meta::Role');
180 $INFO{$role}{methods} = {
181 0 ▶ map +($_ => $role->can($_)),
Condition0%0/3
$is_mouse && $_ eq 'meta'
!ll&&!rl&&r
000
MC/DC0%0/2
$is_mouse && $_ eq 'meta'
$is_mouse $_ eq 'meta'
Truth table0%0/3
A && B
A= $is_mouseB= $_ eq 'meta'
ABresult
0X0
100
111
182 grep $role->can($_),
183 grep !($is_mouse && $_ eq 'meta'),
184 grep !$meta->get_method($_)->isa('Class::MOP::Method::Meta'),
185 $meta->get_method_list
186 };
187 0 $APPLIED_TO{$role} = {
188 map +($_->name => 1), $meta->calculate_all_roles
189 };
190 0 $INFO{$role}{requires} = [ $meta->get_required_method_list ];
191 $INFO{$role}{attributes} = [
192 0 map +($_ => do {
193 0 my $attr = $meta->get_attribute($_);
194 0 ▶ my $spec = { %{ $is_mouse ? $attr : $attr->original_options } };
Branch: 1 branch
BranchTrueFalseTotal
$is_mouse ? : 0 0 0
195  
196 0 ▶ if ($spec->{isa}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec->{"isa"}) 0 0 0
197 0 require Sub::Quote;
198  
199 0 my $get_constraint = do {
200 0 ▶ my $pkg = $is_mouse
Branch: 1 branch
BranchTrueFalseTotal
$is_mouse ? : 0 0 0
201 ? 'Mouse::Util::TypeConstraints'
202 : 'Moose::Util::TypeConstraints';
203 0 _load_module($pkg);
204 0 $pkg->can('find_or_create_isa_type_constraint');
205 };
206  
207 0 my $tc = $get_constraint->($spec->{isa});
208 0 my $check = $tc->_compiled_type_constraint;
209 0 my $tc_var = '$_check_for_'.Sub::Quote::sanitize_identifier($tc->name);
210  
211 0 $spec->{isa} = Sub::Quote::quote_sub(
212 qq{
213 &${tc_var} or Carp::croak "Type constraint failed for \$_[0]"
214 },
215 { $tc_var => \$check },
216 {
217 package => $role,
218 },
219 );
220  
221 0 ▶ if ($spec->{coerce}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec->{"coerce"}) 0 0 0
222  
223 # Mouse has _compiled_type_coercion straight on the TC object
224 0 $spec->{coerce} = $tc->${\(
225 0 ▶ $tc->can('coercion')||sub { $_[0] }
Subroutine __ANON__: not called CC=1 SCAR=6.9
226 0 ▶ )}->_compiled_type_coercion;
Condition0%0/3
$tc->can('coercion') || sub { $_[0]; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$tc->can('coercion') || sub { $_[0]; }
$tc->can('coercion') sub { $_[0]; }
Truth table0%0/3
A || B
A= $tc->can('coercion')B= sub { $_[0]; }
ABresult
1X1
011
000
227 }
228 }
229 0 $spec;
230 }), $meta->get_attribute_list
231 ];
232 0 my $mods = $INFO{$role}{modifiers} = [];
233 0 foreach my $type (qw(before after around)) {
234 # Mouse pokes its own internals so we have to fall back to doing
235 # the same thing in the absence of the Moose API method
236 0 my $map = $meta->${\(
237 $meta->can("get_${type}_method_modifiers_map")
238 0 ▶ or sub { shift->{"${type}_method_modifiers"} }
Subroutine __ANON__: not called CC=1 SCAR=6.9
239 0 ▶ )};
Condition0%0/3
$meta->can("get_${type}_method_modifiers_map") || sub { (shift())->{"${type}_method_modifiers"}; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$meta->can("get_${type}_method_modifiers_map") || sub { (shift())->{"${type}_method_modifiers"}; }
$meta->can("get_${type}_method_modifiers_map") sub { (shift())->{"${type}_method_modifiers"}; }
Truth table0%0/3
A || B
A= $meta->can("get_${type}_method_modifiers_map")B= sub { (shift())->{"${type}_method_modifiers"}; }
ABresult
1X1
011
000
240 0 foreach my $method (keys %$map) {
241 0 foreach my $mod (@{$map->{$method}}) {
242 0 push @$mods, [ $type => $method => $mod ];
243 }
244 }
245 }
246 0 $INFO{$role}{inhaled_from_moose} = 1;
247 0 $INFO{$role}{is_role} = 1;
248 }
249 }
250  
251 15 ▶sub _maybe_make_accessors {
Subroutine _maybe_make_accessors: called CC=6 SCAR=25.0
252 15 my ($self, $target, $role) = @_;
253 15 my $m;
254 15 ▶ if ($INFO{$role} && $INFO{$role}{inhaled_from_moose}
Branch: 1 branch
BranchTrueFalseTotal
if ($Moo::Role::INFO{$role} and $Moo::Role::INFO{$role}{"inhaled_from_moose"} or $INC{"Moo.pm"} and $m = "Moo"->_accessor_maker_for($target) and ref $m ne "Method::Generate::Accessor") 0 15 15
Condition33%4/12
$Moo::Role::INFO{$role} and $Moo::Role::INFO{$role}{"inhaled_from_moose"} or $INC{"Moo.pm"} and $m = "Moo"->_accessor_maker_for($target) and ref $m ne "Method::Generate::Accessor"
l!l&&r!l&&!r
0015
$Moo::Role::INFO{$role} and $Moo::Role::INFO{$role}{"inhaled_from_moose"}
!ll&&!rl&&r
0150
$INC{"Moo.pm"} and $m = "Moo"->_accessor_maker_for($target) and ref $m ne "Method::Generate::Accessor"
!ll&&!rl&&r
0150
$INC{"Moo.pm"} and $m = "Moo"->_accessor_maker_for($target)
!ll&&!rl&&r
0015
MC/DC0%0/5
$Moo::Role::INFO{$role} and $Moo::Role::INFO{$role}{"inhaled_from_moose"} or $INC{"Moo.pm"} and $m = "Moo"->_accessor_maker_for($target) and ref $m ne "Method::Generate::Accessor"
$Moo::Role::INFO{$role} $Moo::Role::INFO{$role}{"inhaled_from_moose"} $INC{"Moo.pm"} $m = "Moo"->_accessor_maker_for($target) ref $m ne "Method::Generate::Accessor"
Truth table11%1/9
A and B or C and D and E
A= $Moo::Role::INFO{$role}B= $Moo::Role::INFO{$role}{"inhaled_from_moose"}C= $INC{"Moo.pm"}D= $m = "Moo"->_accessor_maker_for($target)E= ref $m ne "Method::Generate::Accessor"
ABCDEresult
11XXX1
0X1111
101111
0X0XX0
0X10X0
0X1100
100XX0
1010X0
101100
255 or $INC{"Moo.pm"}
256 and $m = Moo->_accessor_maker_for($target)
257 and ref($m) ne 'Method::Generate::Accessor') {
258 0 $self->_make_accessors($target, $role);
259 }
260 }
261  
262 0 ▶sub _make_accessors_if_moose {
Subroutine _make_accessors_if_moose: not called CC=3 SCAR=24.8
263 0 my ($self, $target, $role) = @_;
264 0 ▶ if ($INFO{$role} && $INFO{$role}{inhaled_from_moose}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Moo::Role::INFO{$role} and $Moo::Role::INFO{$role}{"inhaled_from_moose"}) 0 0 0
Condition0%0/3
$Moo::Role::INFO{$role} and $Moo::Role::INFO{$role}{"inhaled_from_moose"}
!ll&&!rl&&r
000
MC/DC0%0/2
$Moo::Role::INFO{$role} and $Moo::Role::INFO{$role}{"inhaled_from_moose"}
$Moo::Role::INFO{$role} $Moo::Role::INFO{$role}{"inhaled_from_moose"}
Truth table0%0/3
A and B
A= $Moo::Role::INFO{$role}B= $Moo::Role::INFO{$role}{"inhaled_from_moose"}
ABresult
0X0
100
111
265 0 $self->_make_accessors($target, $role);
266 }
267 }
268  
269 0 ▶sub _make_accessors {
Subroutine _make_accessors: not called CC=5 SCAR=34.0
270 0 my ($self, $target, $role) = @_;
271 0 ▶ my $acc_gen = ($Moo::MAKERS{$target}{accessor} ||= do {
Condition0%0/3
$Moo::MAKERS{$target}{"accessor"} ||= do { require Method::Generate::Accessor; "Method::Generate::Accessor"->new }
l!l&&r!l&&!r
000
MC/DC0%0/2
$Moo::MAKERS{$target}{"accessor"} ||= do { require Method::Generate::Accessor; "Method::Generate::Accessor"->new }
$Moo::MAKERS{$target}{"accessor"} do { require Method::Generate::Accessor; "Method::Generate::Accessor"->new }
Truth table0%0/3
A ||= B
A= $Moo::MAKERS{$target}{"accessor"}B= do { require Method::Generate::Accessor; "Method::Generate::Accessor"->new }
ABresult
1X1
011
000
272 0 require Method::Generate::Accessor;
273 0 Method::Generate::Accessor->new
274 });
275 0 my $con_gen = $Moo::MAKERS{$target}{constructor};
276 0 ▶ my @attrs = @{$INFO{$role}{attributes}||[]};
Condition0%0/2
$Moo::Role::INFO{$role}{'attributes'} || []
l!l
00
MC/DC0%0/1
$Moo::Role::INFO{$role}{'attributes'} || []
$Moo::Role::INFO{$role}{'attributes'}
Truth table0%0/2
A
A= $Moo::Role::INFO{$role}{'attributes'}
Aresult
11
00
277 0 ▶ while (my ($name, $spec) = splice @attrs, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@attrs, 0, 2)) 0 0 0
278 # needed to ensure we got an index for an arrayref based generator
279 0 ▶ if ($con_gen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($con_gen) 0 0 0
280 0 $spec = $con_gen->all_attribute_specs->{$name};
281 }
282 0 $acc_gen->generate_method($target, $name, $spec);
283 }
284 }
285  
286 15 ▶sub _undefer_subs {
Subroutine _undefer_subs: called CC=2 SCAR=7.1
287 15 my ($self, $target, $role) = @_;
288 15 ▶ if ($INC{'Sub/Defer.pm'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"Sub/Defer.pm"}) 15 0 15
289 15 Sub::Defer::undefer_package($role);
290 }
291 }
292  
293 15 ▶sub role_application_steps {
Subroutine role_application_steps: called CC=1 SCAR=0.0
Pod undocumented
294 15 qw(_handle_constructor _undefer_subs _maybe_make_accessors),
295 $_[0]->SUPER::role_application_steps;
296 }
297  
298 0 ▶sub _build_class_with_roles {
Subroutine _build_class_with_roles: not called CC=8 SCAR=42.8
299 0 my ($me, $new_name, $superclass, @roles) = @_;
300 0 $Moo::MAKERS{$new_name} = {is_class => 1};
301 0 $me->SUPER::_build_class_with_roles($new_name, $superclass, @roles);
302  
303 0 ▶ if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"Moo/HandleMoose.pm"} and not $Moo::sification::disabled) 0 0 0
Condition0%0/3
$INC{"Moo/HandleMoose.pm"} and not $Moo::sification::disabled
!ll&&!rl&&r
000
MC/DC0%0/2
$INC{"Moo/HandleMoose.pm"} and not $Moo::sification::disabled
$INC{"Moo/HandleMoose.pm"} not $Moo::sification::disabled
Truth table0%0/3
A and not(B)
A= $INC{"Moo/HandleMoose.pm"}B= not $Moo::sification::disabled
ABresult
0X0
100
111
304 0 Moo::HandleMoose::inject_fake_metaclass_for($new_name);
305 }
306  
307 0 my $lvl = 0;
308 0 my $file;
309 0 ▶ while ((my $pack, $file) = caller($lvl++)) {
Branch: 1 branch
BranchTrueFalseTotal
if ((my $pack, $file) = caller $lvl++) 0 0 0
310 0 ▶ if ($pack ne __PACKAGE__ && $pack ne 'Role::Tiny' && !$pack->isa($me)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pack ne __PACKAGE__ and $pack ne "Role::Tiny" and not $pack->isa($me)) 0 0 0
Condition0%0/6
$pack ne __PACKAGE__ and $pack ne "Role::Tiny" and not $pack->isa($me)
!ll&&!rl&&r
000
$pack ne __PACKAGE__ and $pack ne "Role::Tiny"
!ll&&!rl&&r
000
MC/DC0%0/3
$pack ne __PACKAGE__ and $pack ne "Role::Tiny" and not $pack->isa($me)
$pack ne __PACKAGE__ $pack ne "Role::Tiny" not $pack->isa($me)
Truth table0%0/4
A and B and not(C)
A= $pack ne __PACKAGE__B= $pack ne "Role::Tiny"C= not $pack->isa($me)
ABCresult
0XX0
10X0
1100
1111
311 0 last;
312 }
313 }
314 0 ▶ _set_loaded($new_name, $file || (caller)[1]);
Condition0%0/3
$file || (caller)[1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$file || (caller)[1]
$file (caller)[1]
Truth table0%0/3
A || B
A= $fileB= (caller)[1]
ABresult
1X1
011
000
315  
316 0 return $new_name;
317 }
318  
319 0 ▶sub _gen_apply_defaults_for {
Subroutine _gen_apply_defaults_for: not called CC=10 SCAR=45.1
320 0 my ($me, $class, @roles) = @_;
321  
322 0 ▶ my @attrs = map @{$INFO{$_}{attributes}||[]}, @roles;
Condition0%0/2
$Moo::Role::INFO{$_}{'attributes'} || []
l!l
00
MC/DC0%0/1
$Moo::Role::INFO{$_}{'attributes'} || []
$Moo::Role::INFO{$_}{'attributes'}
Truth table0%0/2
A
A= $Moo::Role::INFO{$_}{'attributes'}
Aresult
11
00
323  
324 0 my $con_gen;
325 my $m;
326  
327 return undef
328 0 ▶ unless $INC{'Moo.pm'}
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"Moo.pm"} and @attrs and $con_gen = "Moo"->_constructor_maker_for($class) and $m = "Moo"->_accessor_maker_for($class) 0 0 0
Condition0%0/9
$INC{"Moo.pm"} and @attrs and $con_gen = "Moo"->_constructor_maker_for($class) and $m = "Moo"->_accessor_maker_for($class)
!ll&&!rl&&r
000
$INC{"Moo.pm"} and @attrs and $con_gen = "Moo"->_constructor_maker_for($class)
!ll&&!rl&&r
000
$INC{"Moo.pm"} and @attrs
!ll&&!rl&&r
000
MC/DC0%0/4
$INC{"Moo.pm"} and @attrs and $con_gen = "Moo"->_constructor_maker_for($class) and $m = "Moo"->_accessor_maker_for($class)
$INC{"Moo.pm"} @attrs $con_gen = "Moo"->_constructor_maker_for($class) $m = "Moo"->_accessor_maker_for($class)
Truth table0%0/5
A and B and C and D
A= $INC{"Moo.pm"}B= @attrsC= $con_gen = "Moo"->_constructor_maker_for($class)D= $m = "Moo"->_accessor_maker_for($class)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
329 and @attrs
330 and $con_gen = Moo->_constructor_maker_for($class)
331 and $m = Moo->_accessor_maker_for($class);
332  
333 0 my $specs = $con_gen->all_attribute_specs;
334  
335 0 my %seen;
336 my %captures;
337 0 my @set;
338 0 ▶ while (my ($name, $spec) = splice @attrs, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@attrs, 0, 2)) 0 0 0
339 next
340 0 ▶ if $seen{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$name}++ 0 0 0
341  
342 next
343 0 ▶ unless $m->has_eager_default($name, $spec);
Branch: 1 branch
BranchTrueFalseTotal
unless $m->has_eager_default($name, $spec) 0 0 0
344  
345 0 my ($has, $has_cap)
346 = $m->generate_simple_has('$_[0]', $name, $spec);
347 0 my ($set, $pop_cap)
348 = $m->generate_use_default('$_[0]', $name, $spec, $has);
349  
350 0 @captures{keys %$has_cap, keys %$pop_cap}
351 = (values %$has_cap, values %$pop_cap);
352  
353 0 push @set, $set;
354 }
355  
356 return undef
357 0 ▶ if !@set;
Branch: 1 branch
BranchTrueFalseTotal
unless @set 0 0 0
358  
359 0 my $code = join '', map "($_),", @set;
360 5 ▶ no warnings 'void';
Subroutine BEGIN: called CC=1 SCAR=0.0
361 0 require Sub::Quote;
362 0 return Sub::Quote::quote_sub(
363 "${class}::_apply_defaults",
364 $code,
365 \%captures,
366 {
367 package => $class,
368 no_install => 1,
369 no_defer => 1,
370 }
371 );
372 }
373  
374 0 ▶sub apply_roles_to_object {
Subroutine apply_roles_to_object: not called CC=3 SCAR=24.8
Pod documented
375 0 my ($me, $object, @roles) = @_;
376 0 my $new = $me->SUPER::apply_roles_to_object($object, @roles);
377 0 my $class = ref $new;
378 0 _set_loaded($class, (caller)[1]);
379  
380 0 ▶ if (!exists $APPLY_DEFAULTS{$class}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Moo::Role::APPLY_DEFAULTS{$class}) 0 0 0
381 0 $APPLY_DEFAULTS{$class} = $me->_gen_apply_defaults_for($class, @roles);
382 }
383 0 ▶ if (my $apply_defaults = $APPLY_DEFAULTS{$class}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $apply_defaults = $Moo::Role::APPLY_DEFAULTS{$class}) 0 0 0
384 0 local $Carp::Internal{+__PACKAGE__} = 1;
385 0 local $Carp::Internal{$class} = 1;
386 0 $new->$apply_defaults;
387 }
388 0 return $new;
389 }
390  
391 0 ▶sub _install_single_modifier {
Subroutine _install_single_modifier: not called CC=1 SCAR=6.9
392 0 my ($me, @args) = @_;
393 0 _install_modifier(@args);
394 }
395  
396 15 ▶sub _install_does {
Subroutine _install_does: called CC=2 SCAR=7.1
397 15 my ($me, $to) = @_;
398  
399 # If Role::Tiny actually installed the DOES, give it a name
400 15 ▶ my $new = $me->SUPER::_install_does($to) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $new = $me->SUPER::_install_does($to) or return 15 0 15
401 15 return _name_coderef("${to}::DOES", $new);
402 }
403  
404 0 ▶sub does_role {
Subroutine does_role: not called CC=6 SCAR=37.4
Pod documented
405 0 my ($proto, $role) = @_;
406 0 ▶ return 1
Branch: 1 branch
BranchTrueFalseTotal
if Role::Tiny::does_role($proto, $role) 0 0 0
407 if Role::Tiny::does_role($proto, $role);
408 0 my $meta;
409 0 ▶ if ($INC{'Moose.pm'}
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"Moose.pm"} and $meta = Class::MOP::class_of($proto) and ref $meta ne "Moo::HandleMoose::FakeMetaClass" and $meta->can("does_role")) 0 0 0
Condition0%0/9
$INC{"Moose.pm"} and $meta = Class::MOP::class_of($proto) and ref $meta ne "Moo::HandleMoose::FakeMetaClass" and $meta->can("does_role")
!ll&&!rl&&r
000
$INC{"Moose.pm"} and $meta = Class::MOP::class_of($proto) and ref $meta ne "Moo::HandleMoose::FakeMetaClass"
!ll&&!rl&&r
000
$INC{"Moose.pm"} and $meta = Class::MOP::class_of($proto)
!ll&&!rl&&r
000
MC/DC0%0/4
$INC{"Moose.pm"} and $meta = Class::MOP::class_of($proto) and ref $meta ne "Moo::HandleMoose::FakeMetaClass" and $meta->can("does_role")
$INC{"Moose.pm"} $meta = Class::MOP::class_of($proto) ref $meta ne "Moo::HandleMoose::FakeMetaClass" $meta->can("does_role")
Truth table0%0/5
A and B and C and D
A= $INC{"Moose.pm"}B= $meta = Class::MOP::class_of($proto)C= ref $meta ne "Moo::HandleMoose::FakeMetaClass"D= $meta->can("does_role")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
410 and $meta = Class::MOP::class_of($proto)
411 and ref $meta ne 'Moo::HandleMoose::FakeMetaClass'
412 and $meta->can('does_role')
413 ) {
414 0 return $meta->does_role($role);
415 }
416 0 return 0;
417 }
418  
419 15 ▶sub _handle_constructor {
Subroutine _handle_constructor: called CC=13 SCAR=48.0
420 15 my ($me, $to, $role) = @_;
421 15 ▶ my $attr_info = $INFO{$role} && $INFO{$role}{attributes};
Condition33%1/3
$Moo::Role::INFO{$role} && $Moo::Role::INFO{$role}{'attributes'}
!ll&&!rl&&r
0150
MC/DC0%0/2
$Moo::Role::INFO{$role} && $Moo::Role::INFO{$role}{'attributes'}
$Moo::Role::INFO{$role} $Moo::Role::INFO{$role}{'attributes'}
Truth table33%1/3
A && B
A= $Moo::Role::INFO{$role}B= $Moo::Role::INFO{$role}{'attributes'}
ABresult
0X0
100
111
422 15 ▶ return unless $attr_info && @$attr_info;
Branch: 1 branch
BranchTrueFalseTotal
unless $attr_info and @$attr_info 15 0 15
Condition33%1/3
$attr_info and @$attr_info
!ll&&!rl&&r
1500
MC/DC0%0/2
$attr_info and @$attr_info
$attr_info @$attr_info
Truth table33%1/3
A and B
A= $attr_infoB= @$attr_info
ABresult
0X0
100
111
423 0 my $info = $INFO{$to};
424 0 ▶ my $con = $INC{"Moo.pm"} && Moo->_constructor_maker_for($to);
Condition0%0/3
$INC{'Moo.pm'} && 'Moo'->_constructor_maker_for($to)
!ll&&!rl&&r
000
MC/DC0%0/2
$INC{'Moo.pm'} && 'Moo'->_constructor_maker_for($to)
$INC{'Moo.pm'} 'Moo'->_constructor_maker_for($to)
Truth table0%0/3
A && B
A= $INC{'Moo.pm'}B= 'Moo'->_constructor_maker_for($to)
ABresult
0X0
100
111
425 my %existing
426 0 ▶ = $info ? @{$info->{attributes} || []}
Branch: 1 branch
BranchTrueFalseTotal
$con ? : 0 0 0
Condition0%0/2
$info->{'attributes'} || []
l!l
00
MC/DC0%0/1
$info->{'attributes'} || []
$info->{'attributes'}
Truth table0%0/2
A
A= $info->{'attributes'}
Aresult
11
00
427 0 ▶ : $con ? %{$con->all_attribute_specs || {}}
Branch: 1 branch
BranchTrueFalseTotal
$info ? : 0 0 0
Condition0%0/2
$con->all_attribute_specs || {}
l!l
00
MC/DC0%0/1
$con->all_attribute_specs || {}
$con->all_attribute_specs
Truth table0%0/2
A
A= $con->all_attribute_specs
Aresult
11
00
428 : ();
429  
430 my @attr_info =
431 0 map { @{$attr_info}[$_, $_+1] }
432 0 grep { ! $existing{$attr_info->[$_]} }
433 0 map { 2 * $_ } 0..@$attr_info/2-1;
434  
435 0 ▶ if ($info) {
Branch: 2 branches
BranchTrueFalseTotal
if ($info) { } 0 0 0
elsif ($con) { } 0 0 0
436 0 ▶ push @{$info->{attributes}||=[]}, @attr_info;
Condition0%0/2
$info->{"attributes"} ||= []
l!l
00
MC/DC0%0/1
$info->{"attributes"} ||= []
$info->{"attributes"}
Truth table0%0/2
A
A= $info->{"attributes"}
Aresult
11
00
437 }
438 elsif ($con) {
439 # shallow copy of the specs since the constructor will assign an index
440 0 ▶ $con->register_attribute_specs(map ref() ? { %$_ } : $_, @attr_info);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 0 0
441 }
442 }
443  
444 5 1;
445 __END__
« /usr/local/lib/perl5/5.44.0/CPAN/Meta/Prereqs.pm ↑ Summary /usr/local/lib/perl5/5.44.0/x86_64-linux/Config_heavy.pl »