| 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
Condition50%1/2
$self->superclasses || []
MC/DC0%0/1
$self->superclasses || []
$self->superclasses
Truth table50%1/2
A
A= $self->superclasses
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 74 | 2 | $found_signature = $parent->method_signatures->{$name}; | |||||||||||||||||||
| 75 | 2 | last; | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 2 | ▶ | if ( $found_signature ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | 2 | ▶ | $self->method_signatures->{$name} = %args | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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; | |||||||||||||||||||