lib/Mite/Trait/HasRequiredMethods.pm.mite.pm

filter: Statementstmt 71.2% 67 / 94 Branchbran 20.0% 4 / 20 Conditioncond 12.5% 2 / 16 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 57.1% 12 / 21 Podpod 0.0% 0 / 2 totaltotal 52.1% 85 / 163 CC 19 SCAR 29.5
CC
19
Cov
56%
DOES
72.0
__META__
14.3
__FINALIZE_APPLICATION__
9.7
CRAP 19.1
« lib/Mite/Trait/HasDestructor.pm.mite.pm ↑ Summary lib/Mite/Trait/HasSuperclasses.pm.mite.pm »
1 {
2  
3 19 package Mite::Trait::HasRequiredMethods;
4 19 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶ no warnings qw( once void );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 19 our $USES_MITE = "Mite::Role";
9 19 our $MITE_SHIM = "Mite::Shim";
10 19 our $MITE_VERSION = "0.013000";
11  
12 # Mite keywords
13 19 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.4
14 19 my ( $SHIM, $CALLER ) =
15 ( "Mite::Shim", "Mite::Trait::HasRequiredMethods" );
16 (
17 *after, *around, *before,
18 *field, *has, *param,
19 *requires, *signature_for, *with
20 )
21 19 = do {
22  
23 package Mite::Shim;
24 19 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
25 (
26 0 ▶ sub { $SHIM->HANDLE_after( $CALLER, "role", @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 19 ▶ sub { $SHIM->HANDLE_around( $CALLER, "role", @_ ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
28 19 ▶ sub { $SHIM->HANDLE_before( $CALLER, "role", @_ ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
29 0 ▶ sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 19 ▶ sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
31 0 ▶ sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 0 ▶ sub { },
Subroutine __ANON__: not called CC=1 SCAR=0.0
33 0 ▶ sub { $SHIM->HANDLE_signature_for( $CALLER, "role", @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 0 ▶ sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 19 );
36 };
37 }
38  
39 # Mite imports
40 19 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
41 19 require Scalar::Util;
42 19 *STRICT = \&Mite::Shim::STRICT;
43 19 *bare = \&Mite::Shim::bare;
44 19 *blessed = \&Scalar::Util::blessed;
45 19 *carp = \&Mite::Shim::carp;
46 19 *confess = \&Mite::Shim::confess;
47 19 *croak = \&Mite::Shim::croak;
48 19 *false = \&Mite::Shim::false;
49 19 *guard = \&Mite::Shim::guard;
50 19 *lazy = \&Mite::Shim::lazy;
51 19 *lock = \&Mite::Shim::lock;
52 19 *ro = \&Mite::Shim::ro;
53 19 *rw = \&Mite::Shim::rw;
54 19 *rwp = \&Mite::Shim::rwp;
55 19 *true = \&Mite::Shim::true;
56 19 *unlock = \&Mite::Shim::unlock;
57 }
58  
59 # Gather metadata for constructor and destructor
60 0 ▶ sub __META__ {
Subroutine __META__: not called CC=4 SCAR=26.6
61 19 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
62 0 my $class = shift;
63 0 ▶ $class = ref($class) || $class;
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
64 0 my $linear_isa = mro::get_linear_isa($class);
65 return {
66 BUILD => [
67 0 ▶ map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
Branch: 1 branch
BranchTrueFalseTotal
*{$_;}{'CODE'} ? : 0 0 0
68 0 map { "$_\::BUILD" } reverse @$linear_isa
69 ],
70 DEMOLISH => [
71 0 ▶ map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
Branch: 1 branch
BranchTrueFalseTotal
*{$_;}{'CODE'} ? : 0 0 0
72 0 map { "$_\::DEMOLISH" } @$linear_isa
73 ],
74 HAS_BUILDARGS => $class->can('BUILDARGS'),
75 HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
76 };
77 }
78  
79 # See UNIVERSAL
80 0 ▶ sub DOES {
Subroutine DOES: not called CC=8 SCAR=42.8
Pod undocumented
81 0 my ( $self, $role ) = @_;
82 0 our %DOES;
83 0 ▶ return $DOES{$role} if exists $DOES{$role};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Mite::Trait::HasRequiredMethods::DOES{$role} 0 0 0
84 0 ▶ return 1 if $role eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $role eq __PACKAGE__ 0 0 0
85 0 ▶ if ( $INC{'Moose/Util.pm'}
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"Moose/Util.pm"} and my $meta = Moose::Util::find_meta(ref $self || $self)) 0 0 0
Condition0%0/6
$INC{"Moose/Util.pm"} and my $meta = Moose::Util::find_meta(ref $self || $self)
!ll&&!rl&&r
000
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
$INC{"Moose/Util.pm"} and my $meta = Moose::Util::find_meta(ref $self || $self)
$INC{"Moose/Util.pm"} my $meta = Moose::Util::find_meta(ref $self || $self)
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A and B
A= $INC{"Moose/Util.pm"}B= my $meta = Moose::Util::find_meta(ref $self || $self)
ABresult
0X0
100
111
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
86 and my $meta = Moose::Util::find_meta( ref $self or $self ) )
87 {
88 0 ▶ $meta->can('does_role') and $meta->does_role($role) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$meta->can("does_role") and $meta->does_role($role) and return 1 0 0 0
Condition0%0/3
$meta->can("does_role") and $meta->does_role($role)
!ll&&!rl&&r
000
MC/DC0%0/2
$meta->can("does_role") and $meta->does_role($role)
$meta->can("does_role") $meta->does_role($role)
Truth table0%0/3
A and B
A= $meta->can("does_role")B= $meta->does_role($role)
ABresult
0X0
100
111
89 }
90 0 return $self->SUPER::DOES($role);
91 }
92  
93 # Alias for Moose/Moo-compatibility
94 0 ▶ sub does {
Subroutine does: not called CC=1 SCAR=6.9
Pod undocumented
95 0 shift->DOES(@_);
96 }
97  
98 # Callback which classes consuming this role will call
99 19 ▶ sub __FINALIZE_APPLICATION__ {
Subroutine __FINALIZE_APPLICATION__: called CC=9 SCAR=22.7
100 19 my ( $me, $target, $args ) = @_;
101 19 our ( %CONSUMERS, @METHOD_MODIFIERS );
102  
103 # Ensure a given target only consumes this role once.
104 19 ▶ if ( exists $CONSUMERS{$target} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Mite::Trait::HasRequiredMethods::CONSUMERS{$target}) 0 19 19
105 0 return;
106 }
107 19 $CONSUMERS{$target} = 1;
108  
109 19 ▶ my $type = do { no strict 'refs'; ${"$target\::USES_MITE"} };
Subroutine BEGIN: called CC=1 SCAR=0.0
110 19 ▶ return if $type ne 'Mite::Class';
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "Mite::Class" 0 19 19
111  
112 19 my @missing_methods;
113 19 ▶ @missing_methods = grep( !$target->can($_),
Branch: 1 branch
BranchTrueFalseTotal
@missing_methods = grep((!$target->can($_)), "_compile_mop_required_methods", "inject_mite_functions") and croak("$me requires $target to implement methods: " . join(", ", @missing_methods)) 0 19 19
114 "_compile_mop_required_methods",
115 "inject_mite_functions" )
116 and croak( "$me requires $target to implement methods: " . join q[, ],
117 @missing_methods );
118  
119 19 my @roles = ();
120 19 ▶ my %nextargs = %{ $args || {} };
Condition50%1/2
$args || {}
l!l
019
MC/DC0%0/1
$args || {}
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
121 19 ▶ ( $nextargs{-indirect} ||= 0 )++;
Condition50%1/2
$nextargs{"-indirect"} ||= 0
l!l
019
MC/DC0%0/1
$nextargs{"-indirect"} ||= 0
$nextargs{"-indirect"}
Truth table50%1/2
A
A= $nextargs{"-indirect"}
Aresult
11
00
122 19 ▶ croak("PANIC!") if $nextargs{-indirect} > 100;
Branch: 1 branch
BranchTrueFalseTotal
if $nextargs{"-indirect"} > 100 0 19 19
123 19 for my $role (@roles) {
124 0 $role->__FINALIZE_APPLICATION__( $target, {%nextargs} );
125 }
126  
127 19 my $shim = "Mite::Shim";
128 19 for my $modifier_rule (@METHOD_MODIFIERS) {
129 38 my ( $modification, $names, $coderef ) = @$modifier_rule;
130 38 my $handler = "HANDLE_$modification";
131 38 $shim->$handler( $target, "class", $names, $coderef );
132 }
133  
134 19 return;
135 }
136  
137 19 1;
138 }
« lib/Mite/Trait/HasDestructor.pm.mite.pm ↑ Summary lib/Mite/Trait/HasSuperclasses.pm.mite.pm »