| 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
Condition100%3/3
@args and not $self->name->isa("Mouse::Object")
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")
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
defined $super_meta and $super_meta->does(__PACKAGE__)
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__)
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 35 | 41 | $traits{constructor} = ['MouseX::Foreign::Meta::Role::Method::Constructor']; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 41 | ▶ | if($super->can('DESTROY')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 4 | $traits{destructor} = ['MouseX::Foreign::Meta::Role::Method::Destructor']; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 41 | ▶ | if(%traits) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||