lib/Mite/Class.pm

filter: Statementstmt 95.7% 67 / 70 Branchbran 78.5% 11 / 14 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 88.2% 15 / 17 Podpod 0.0% 0 / 5 totaltotal 86.2% 94 / 109 CC 12 SCAR 9.8
CC
12
Cov
92%
extend_method_signature
5.1
__ANON__
4.0
__ANON__
3.0
CRAP 2.7
« lib/Mite/App/Command.pm ↑ Summary lib/Mite/App.pm »
1 117 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 117 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 117 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Mite::Class;
6 117 ▶use Mite::Miteception -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 117 extends qw(
8 Mite::Package
9 );
10 117 with qw(
11 Mite::Trait::HasSuperclasses
12 Mite::Trait::HasConstructor
13 Mite::Trait::HasDestructor
14 Mite::Trait::HasAttributes
15 Mite::Trait::HasRoles
16 Mite::Trait::HasMethods
17 Mite::Trait::HasMOP
18 );
19  
20 117 our $AUTHORITY = 'cpan:TOBYINK';
21 117 our $VERSION = '0.013000';
22  
23 117 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 117 ▶use mro;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 117 ▶use B ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 218 ▶sub kind { 'class' }
Subroutine kind: called CC=1 SCAR=0.0
Pod undocumented
28  
29 2 ▶sub class {
Subroutine class: called CC=1 SCAR=0.0
Pod undocumented
30 2 my ( $self, $name ) = ( shift, @_ );
31  
32 2 return $self->project->class($name);
33 }
34  
35 61 ▶sub chained_attributes {
Subroutine chained_attributes: called CC=3 SCAR=11.0
Pod undocumented
36 61 my ( $self, @classes ) = ( shift, @_ );
37  
38 61 my %attributes;
39 61 for my $class (reverse @classes) {
40 129 for my $attribute (values %{$class->attributes}) {
41 111 $attributes{$attribute->name} = $attribute;
42 }
43 }
44  
45 61 return \%attributes;
46 }
47  
48 333 ▶around all_attributes => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
49 333 my ( $next, $self ) = ( shift, shift );
50  
51 return $self->$next
52 333 ▶ if not @{ $self->superclasses || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->superclasses or [];} 277 56 333
Condition50%1/2
$self->superclasses || []
l!l
3330
MC/DC0%0/1
$self->superclasses || []
$self->superclasses
Truth table50%1/2
A
A= $self->superclasses
Aresult
11
00
53  
54 56 return $self->chained_attributes( $self->linear_parents );
55 117 };
56  
57 5 ▶sub parents_attributes {
Subroutine parents_attributes: called CC=1 SCAR=0.0
Pod undocumented
58 5 my $self = shift;
59  
60 5 my @parents = $self->linear_parents;
61 5 shift @parents; # remove ourselves from the inheritance list
62 5 return $self->chained_attributes(@parents);
63 }
64  
65 2 ▶sub extend_method_signature {
Subroutine extend_method_signature: called CC=5 SCAR=16.3
Pod undocumented
66 2 my ($self, $name, %args) = ( shift, @_ );
67  
68 2 my @parents = $self->linear_parents;
69 2 shift @parents; # remove ourselves from the inheritance list
70  
71 2 my $found_signature;
72 2 for my $parent ( @parents ) {
73 2 ▶ if ( $parent->method_signatures->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->method_signatures->{$name}) 2 0 2
74 2 $found_signature = $parent->method_signatures->{$name};
75 2 last;
76 }
77 }
78  
79 2 ▶ if ( $found_signature ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found_signature) { } 2 0 2
80 2 ▶ $self->method_signatures->{$name} = %args
Branch: 1 branch
BranchTrueFalseTotal
%args ? : 1 1 2
81 ? $found_signature->clone( %args, class => $self )
82 : $found_signature;
83 }
84 else {
85 0 croak "Could not find signature for $name in any parent class";
86 }
87  
88 2 return;
89 }
90  
91 5 ▶around extend_attribute => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
92 5 my ( $next, $self, %attr_args ) = ( shift, shift, @_ );
93  
94 5 my $name = delete $attr_args{name};
95  
96 5 ▶ if ( $self->attributes->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->attributes->{$name}) 1 4 5
97 1 return $self->$next( name => $name, %attr_args );
98 }
99  
100 4 my $parent_attr = $self->parents_attributes->{$name};
101 4 ▶ croak <<'ERROR', $name, $self->name unless $parent_attr;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent_attr 0 4 4
102 Could not find an attribute by the name of '%s' to inherit from in %s
103 ERROR
104  
105 4 ▶ if ( ref $attr_args{default} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attr_args{"default"}) 2 2 4
106 2 $attr_args{_class_for_default} = $self;
107 }
108  
109 4 $self->add_attribute($parent_attr->clone(%attr_args));
110  
111 4 return;
112 117 };
113  
114 118 ▶sub _needs_accessors {
Subroutine _needs_accessors: called CC=1 SCAR=0.0
115 118 return true;
116 }
117  
118 0 ▶sub _mop_metaclass {
Subroutine _mop_metaclass: not called CC=1 SCAR=6.9
119 0 return '$META_CLASS';
120 }
121  
122 0 ▶sub _mop_attribute_metaclass {
Subroutine _mop_attribute_metaclass: not called CC=1 SCAR=6.9
123 0 return 'Moose::Meta::Attribute';
124 }
125  
126 117 1;
« lib/Mite/App/Command.pm ↑ Summary lib/Mite/App.pm »