Foreign/Meta/Role/Class.pm

filter: Statementstmt 100% 36 / 36 Branchbran 83.3% 10 / 12 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 95.3% 62 / 65 CC 9 SCAR 11.9
CC
9
Cov
96%
inherit_from_foreign_class
5.0
__ANON__
3.0
__ANON__
3.0
CRAP 3.3
↑ Summary Foreign/Meta/Role/Method/Constructor.pm »
1 package MouseX::Foreign::Meta::Role::Class;
2 32 ▶use Mouse::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 32 ▶use Mouse::Util::MetaRole;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 32 __PACKAGE__->meta->add_metaclass_accessor('foreign_superclass');
6  
7 47 ▶after superclasses => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
8 47 my($self, @args) = @_;
9 47 ▶ if(@args && !$self->name->isa('Mouse::Object')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and not $self->name->isa("Mouse::Object")) 39 8 47
Condition100%3/3
@args and not $self->name->isa("Mouse::Object")
!ll&&!rl&&r
4439
MC/DC100%2/2
@args and not $self->name->isa("Mouse::Object")
@args not $self->name->isa("Mouse::Object")
Truth table100%3/3
A and not(B)
A= @argsB= not $self->name->isa("Mouse::Object")
ABresult
0X0
100
111
10 39 push @{$self->{superclasses}}, 'Mouse::Object';
11 }
12 47 return;
13 32 };
14  
15 47 ▶before verify_superclass => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
16 47 my($self, $super, $super_meta) = @_;
17  
18 47 ▶ if(defined($super_meta) && $super_meta->does(__PACKAGE__)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $super_meta and $super_meta->does(__PACKAGE__)) 2 45 47
Condition100%3/3
defined $super_meta and $super_meta->does(__PACKAGE__)
!ll&&!rl&&r
4142
MC/DC100%2/2
defined $super_meta and $super_meta->does(__PACKAGE__)
defined $super_meta $super_meta->does(__PACKAGE__)
Truth table100%3/3
A and B
A= defined $super_metaB= $super_meta->does(__PACKAGE__)
ABresult
0X0
100
111
19 2 $self->inherit_from_foreign_class($super);
20 }
21 46 return;
22 32 };
23  
24 43 ▶sub inherit_from_foreign_class { # override
Subroutine inherit_from_foreign_class: called CC=5 SCAR=16.1
Pod undocumented
25 43 my($self, $super) = @_;
26 43 ▶ if(defined $self->foreign_superclass) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->foreign_superclass) 2 41 43
27 2 $self->throw_error(
28 "Multiple inheritance"
29 . " from foreign classes ($super, "
30 . $self->foreign_superclass
31 . ") is forbidden");
32 }
33 41 my %traits;
34 41 ▶ if($super->can('new')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($super->can("new")) 41 0 41
35 41 $traits{constructor} = ['MouseX::Foreign::Meta::Role::Method::Constructor'];
36 }
37 41 ▶ if($super->can('DESTROY')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($super->can("DESTROY")) 4 37 41
38 4 $traits{destructor} = ['MouseX::Foreign::Meta::Role::Method::Destructor'];
39 }
40 41 ▶ if(%traits) {
Branch: 1 branch
BranchTrueFalseTotal
if (%traits) 41 0 41
41 41 $self->foreign_superclass($super);
42 41 $_[0] = $self = Mouse::Util::MetaRole::apply_metaroles(
43 for => $self,
44 class_metaroles => \%traits,
45 );
46  
47 # FIXME
48 41 $self->add_method(
49 new => $self->constructor_class->_generate_constructor($self),
50 );
51 41 $self->add_method(
52 DESTROY => $self->destructor_class->_generate_destructor($self),
53 );
54 }
55 41 return;
56 }
57  
58 32 ▶no Mouse::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 32 1;
60 __END__
↑ Summary Foreign/Meta/Role/Method/Constructor.pm »