| 1 | package Moose::Meta::Class; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 388 | our $VERSION = '2.4001'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 388 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 388 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 388 | ▶ | use Class::MOP; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 388 | ▶ | use Data::OptList; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 388 | ▶ | use List::Util 1.33 qw( any ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 388 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 388 | ▶ | use Moose::Meta::Method::Overridden; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 388 | ▶ | use Moose::Meta::Method::Augmented; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 388 | ▶ | use Moose::Meta::Class::Immutable::Trait; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 388 | ▶ | use Moose::Meta::Method::Constructor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 388 | ▶ | use Moose::Meta::Method::Destructor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 388 | ▶ | use Moose::Meta::Method::Meta; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 388 | ▶ | use Moose::Util 'throw_exception'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 388 | ▶ | use Class::MOP::MiniTrait; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 388 | ▶ | use parent 'Class::MOP::Class'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 388 | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | __PACKAGE__->meta->add_attribute('roles' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 26 | reader => 'roles', | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 2678 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 388 | Class::MOP::_definition_context(), | |||||||||||||||||||||||||||||||||||||||||
| 29 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | __PACKAGE__->meta->add_attribute('role_applications' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 32 | reader => '_get_role_applications', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 2679 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 388 | Class::MOP::_definition_context(), | |||||||||||||||||||||||||||||||||||||||||
| 35 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 388 | __PACKAGE__->meta->add_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 38 | Class::MOP::Attribute->new('immutable_trait' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 39 | accessor => "immutable_trait", | ||||||||||||||||||||||||||||||||||||||||||
| 40 | default => 'Moose::Meta::Class::Immutable::Trait', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 42 | )) | ||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 388 | __PACKAGE__->meta->add_attribute('constructor_class' => ( | |||||||||||||||||||||||||||||||||||||||||
| 46 | accessor => 'constructor_class', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | default => 'Moose::Meta::Method::Constructor', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 49 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 388 | __PACKAGE__->meta->add_attribute('destructor_class' => ( | |||||||||||||||||||||||||||||||||||||||||
| 52 | accessor => 'destructor_class', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | default => 'Moose::Meta::Method::Destructor', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 55 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 2740 | ▶ | sub initialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 2740 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 2740 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 2740 | ▶ | unshift @args, 'package' if @args % 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 2740 | my %opts = @args; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 2740 | my $package = delete $opts{package}; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 2740 | ▶ | return Class::MOP::get_metaclass_by_name($package) | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
Class::MOP::get_metaclass_by_name($package) || $class->SUPER::initialize($package, 'attribute_metaclass', 'Moose::Meta::Attribute', 'method_metaclass', 'Moose::Meta::Method', 'instance_metaclass', 'Moose::Meta::Instance', %opts)
MC/DC0%0/2
Class::MOP::get_metaclass_by_name($package) || $class->SUPER::initialize($package, 'attribute_metaclass', 'Moose::Meta::Attribute', 'method_metaclass', 'Moose::Meta::Method', 'instance_metaclass', 'Moose::Meta::Instance', %opts)
Class::MOP::get_metaclass_by_name($package)
$class->SUPER::initialize($package, 'attribute_metaclass', 'Moose::Meta::Attribute', 'method_metaclass', 'Moose::Meta::Method', 'instance_metaclass', 'Moose::Meta::Instance', %opts)
Truth table66%2/3
A || B
A= Class::MOP::get_metaclass_by_name($package)B= $class->SUPER::initialize($package, 'attribute_metaclass', 'Moose::Meta::Attribute', 'method_metaclass', 'Moose::Meta::Method', 'instance_metaclass', 'Moose::Meta::Instance', %opts)
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | || $class->SUPER::initialize($package, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 'attribute_metaclass' => 'Moose::Meta::Attribute', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 'method_metaclass' => 'Moose::Meta::Method', | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 'instance_metaclass' => 'Moose::Meta::Instance', | ||||||||||||||||||||||||||||||||||||||||||
| 68 | %opts, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 699 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 699 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 699 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 699 | ▶ | unshift @args, 'package' if @args % 2 == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 699 | my %options = @args; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | (ref $options{roles} eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||
| 80 | || throw_exception( RolesInCreateTakesAnArrayRef => params => \%options ) | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 699 | ▶ | if exists $options{roles}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
exists $options{'roles'} && (ref $options{'roles'} eq 'ARRAY' || throw_exception('RolesInCreateTakesAnArrayRef', 'params', \%options))
ref $options{"roles"} eq "ARRAY" or throw_exception("RolesInCreateTakesAnArrayRef", "params", \%options)
MC/DC0%0/3
exists $options{'roles'} && (ref $options{'roles'} eq 'ARRAY' || throw_exception('RolesInCreateTakesAnArrayRef', 'params', \%options))
exists $options{'roles'}
ref $options{"roles"} eq "ARRAY"
throw_exception("RolesInCreateTakesAnArrayRef", "params", \%options)
Truth table0%0/4
A && B or C
A= exists $options{'roles'}B= ref $options{"roles"} eq "ARRAY"C= throw_exception("RolesInCreateTakesAnArrayRef", "params", \%options)
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 697 | my $package = delete $options{package}; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 697 | my $roles = delete $options{roles}; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 697 | my $new_meta = $class->SUPER::create($package, %options); | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 695 | ▶ | if ($roles) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 575 | Moose::Util::apply_all_roles( $new_meta, @$roles ); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 692 | return $new_meta; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 2627 | ▶ | sub _meta_method_class { 'Moose::Meta::Method::Meta' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_meta_method_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 817 | ▶ | sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_anon_package_prefix: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 2718 | ▶ | sub _anon_cache_key { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_anon_cache_key: called CC=14 SCAR=26.7
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 2718 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 2718 | my %options = @_; | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | my $superclass_key = join('|', | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 2718 | ▶ | map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) } | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options{'superclasses'} || []
MC/DC0%0/1
$options{'superclasses'} || []
$options{'superclasses'}
Truth table50%1/2
A
A= $options{'superclasses'}
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | my $roles = Data::OptList::mkopt(($options{roles} || []), { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | moniker => 'role', | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 21 | ▶ | name_test => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 21 | ▶ | ! ref $_[0] or blessed($_[0]) && $_[0]->isa('Moose::Meta::Role') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
!ref($_[0]) || builtin::blessed($_[0]) && $_[0]->isa('Moose::Meta::Role')
builtin::blessed($_[0]) and $_[0]->isa("Moose::Meta::Role")
MC/DC66%2/3
!ref($_[0]) || builtin::blessed($_[0]) && $_[0]->isa('Moose::Meta::Role')
!ref($_[0])
builtin::blessed($_[0])
$_[0]->isa("Moose::Meta::Role")
Truth table75%3/4
not(A) || B and C
A= !ref($_[0])B= builtin::blessed($_[0])C= $_[0]->isa("Moose::Meta::Role")
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 2718 | ▶ | }); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options{'roles'} || []
MC/DC100%1/1
$options{'roles'} || []
$options{'roles'}
Truth table100%2/2
A
A= $options{'roles'}
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 2718 | my @role_keys; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 2718 | for my $role_spec (@$roles) { | |||||||||||||||||||||||||||||||||||||||||
| 116 | 2727 | my ($role, $params) = @$role_spec; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 2727 | ▶ | $params = { %$params } if $params; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 2727 | ▶ | my $key = blessed($role) ? $role->name : $role; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 2727 | ▶ | if ($params && %$params) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$params and %$params
MC/DC50%1/2
$params and %$params
$params
%$params
Truth table66%2/3
A and B
A= $paramsB= %$params
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | my $alias = delete $params->{'-alias'} | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 7 | ▶ | || delete $params->{'alias'} | ||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
delete $params->{'-alias'} || delete $params->{'alias'} || {}
delete $params->{"-alias"} or delete $params->{"alias"}
MC/DC50%1/2
delete $params->{'-alias'} || delete $params->{'alias'} || {}
delete $params->{"-alias"}
delete $params->{"alias"}
Truth table66%2/3
A or B
A= delete $params->{"-alias"}B= delete $params->{"alias"}
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | || {}; | ||||||||||||||||||||||||||||||||||||||||||
| 125 | my $excludes = delete $params->{'-excludes'} | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 7 | ▶ | || delete $params->{'excludes'} | ||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
delete $params->{'-excludes'} || delete $params->{'excludes'} || []
delete $params->{"-excludes"} or delete $params->{"excludes"}
MC/DC50%1/2
delete $params->{'-excludes'} || delete $params->{'excludes'} || []
delete $params->{"-excludes"}
delete $params->{"excludes"}
Truth table66%2/3
A or B
A= delete $params->{"-excludes"}B= delete $params->{"excludes"}
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | || []; | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 7 | ▶ | $excludes = [$excludes] unless ref($excludes) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 7 | ▶ | if (%$params) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | warn "Roles with parameters cannot be cached. Consider " | |||||||||||||||||||||||||||||||||||||||||
| 132 | . "applying the parameters before calling " | ||||||||||||||||||||||||||||||||||||||||||
| 133 | . "create_anon_class, or using 'weaken => 0' instead"; | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | my $alias_key = join('%', | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 7 | map { $_ => $alias->{$_} } sort keys %$alias | |||||||||||||||||||||||||||||||||||||||||
| 139 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 7 | my $excludes_key = join('%', | |||||||||||||||||||||||||||||||||||||||||
| 141 | sort @$excludes | ||||||||||||||||||||||||||||||||||||||||||
| 142 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>'; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 2727 | push @role_keys, $key; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 2718 | my $role_key = join('|', sort @role_keys); | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # Makes something like Super::Class|Super::Class::2=Role|Role::1 | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 2718 | return join('=', $superclass_key, $role_key); | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 105 | ▶ | sub reinitialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reinitialize: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 105 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 105 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 105 | ▶ | my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 105 | my %existing_classes; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 105 | ▶ | if ($meta) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 105 | %existing_classes = map { $_ => $meta->$_() } qw( | |||||||||||||||||||||||||||||||||||||||||
| 164 | attribute_metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 165 | method_metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 166 | wrapped_method_metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 167 | instance_metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 168 | constructor_class | ||||||||||||||||||||||||||||||||||||||||||
| 169 | destructor_class | ||||||||||||||||||||||||||||||||||||||||||
| 170 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 105 | return $self->SUPER::reinitialize( | |||||||||||||||||||||||||||||||||||||||||
| 174 | $pkg, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | %existing_classes, | ||||||||||||||||||||||||||||||||||||||||||
| 176 | @_, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 1100 | ▶ | sub add_role { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_role: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 1100 | my ($self, $role) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 1100 | ▶ | (blessed($role) && $role->isa('Moose::Meta::Role')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($role) and $role->isa("Moose::Meta::Role")
MC/DC100%2/2
builtin::blessed($role) and $role->isa("Moose::Meta::Role")
builtin::blessed($role)
$role->isa("Moose::Meta::Role")
Truth table100%3/3
A and B
A= builtin::blessed($role)B= $role->isa("Moose::Meta::Role")
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | || throw_exception( AddRoleTakesAMooseMetaRoleInstance => role_to_be_added => $role, | ||||||||||||||||||||||||||||||||||||||||||
| 184 | class_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||
| 185 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 1097 | push @{$self->roles} => $role; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 9 | ▶ | sub role_applications { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
role_applications: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 9 | return @{$self->_get_role_applications}; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 1097 | ▶ | sub add_role_application { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_role_application: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 1097 | my ($self, $application) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 1097 | ▶ | (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($application) and $application->isa("Moose::Meta::Role::Application::ToClass")
MC/DC50%1/2
builtin::blessed($application) and $application->isa("Moose::Meta::Role::Application::ToClass")
builtin::blessed($application)
$application->isa("Moose::Meta::Role::Application::ToClass")
Truth table66%2/3
A and B
A= builtin::blessed($application)B= $application->isa("Moose::Meta::Role::Application::ToClass")
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | || throw_exception( InvalidRoleApplication => class_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||
| 200 | application => $application, | ||||||||||||||||||||||||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 1096 | push @{$self->_get_role_applications} => $application; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 352 | ▶ | sub calculate_all_roles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calculate_all_roles: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 352 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 352 | my %seen; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 352 | grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles }; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 122 | ▶ | sub _roles_with_inheritance { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_roles_with_inheritance: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 122 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 122 | my %seen; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 131 | grep { !$seen{$_->name}++ } | |||||||||||||||||||||||||||||||||||||||||
| 216 | 122 | map { Class::MOP::class_of($_)->can('roles') | |||||||||||||||||||||||||||||||||||||||||
| 217 | 1187 | ▶ | ? @{ Class::MOP::class_of($_)->roles } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | : () } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | $self->linearized_isa; | ||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 22 | ▶ | sub calculate_all_roles_with_inheritance { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calculate_all_roles_with_inheritance: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 22 | my %seen; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 33 | grep { !$seen{$_->name}++ } | |||||||||||||||||||||||||||||||||||||||||
| 226 | 22 | ▶ | map { Class::MOP::class_of($_)->can('calculate_all_roles') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | ? Class::MOP::class_of($_)->calculate_all_roles | ||||||||||||||||||||||||||||||||||||||||||
| 228 | : () } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | $self->linearized_isa; | ||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 489 | ▶ | sub does_role { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
does_role: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 489 | my ($self, $role_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 489 | ▶ | (defined $role_name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | || throw_exception( RoleNameRequired => class_name => $self->name ); | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 487 | foreach my $class ($self->class_precedence_list) { | |||||||||||||||||||||||||||||||||||||||||
| 239 | 946 | my $meta = Class::MOP::class_of($class); | |||||||||||||||||||||||||||||||||||||||||
| 240 | # when a Moose metaclass is itself extended with a role, | ||||||||||||||||||||||||||||||||||||||||||
| 241 | # this check needs to be done since some items in the | ||||||||||||||||||||||||||||||||||||||||||
| 242 | # class_precedence_list might in fact be Class::MOP | ||||||||||||||||||||||||||||||||||||||||||
| 243 | # based still. | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 946 | ▶ | next unless $meta && $meta->can('roles'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$meta and $meta->can("roles")
MC/DC50%1/2
$meta and $meta->can("roles")
$meta
$meta->can("roles")
Truth table66%2/3
A and B
A= $metaB= $meta->can("roles")
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 668 | foreach my $role (@{$meta->roles}) { | |||||||||||||||||||||||||||||||||||||||||
| 246 | 459 | ▶ | return 1 if $role->does_role($role_name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 128 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 1127 | ▶ | sub excludes_role { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
excludes_role: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 1127 | my ($self, $role_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 1127 | ▶ | (defined $role_name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | || throw_exception( RoleNameRequired => class_name => $self->name ); | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 1126 | foreach my $class ($self->class_precedence_list) { | |||||||||||||||||||||||||||||||||||||||||
| 259 | 10446 | my $meta = Class::MOP::class_of($class); | |||||||||||||||||||||||||||||||||||||||||
| 260 | # when a Moose metaclass is itself extended with a role, | ||||||||||||||||||||||||||||||||||||||||||
| 261 | # this check needs to be done since some items in the | ||||||||||||||||||||||||||||||||||||||||||
| 262 | # class_precedence_list might in fact be Class::MOP | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # based still. | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 10446 | ▶ | next unless $meta && $meta->can('roles'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$meta and $meta->can("roles")
MC/DC50%1/2
$meta and $meta->can("roles")
$meta
$meta->can("roles")
Truth table66%2/3
A and B
A= $metaB= $meta->can("roles")
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 2188 | foreach my $role (@{$meta->roles}) { | |||||||||||||||||||||||||||||||||||||||||
| 266 | 116 | ▶ | return 1 if $role->excludes_role($role_name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 1120 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 3764 | ▶ | sub new_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_object: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 3764 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 3764 | ▶ | my $params = @_ == 1 ? $_[0] : {@_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 3764 | my $object = $self->SUPER::new_object($params); | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 2772 | $self->_call_all_triggers($object, $params); | |||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 2772 | ▶ | $object->BUILDALL($params) if $object->can('BUILDALL'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 2763 | return $object; | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 2851 | ▶ | sub _call_all_triggers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_call_all_triggers: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 2851 | my ($self, $object, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 2851 | foreach my $attr ( $self->get_all_attributes() ) { | |||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 12835 | ▶ | next unless $attr->can('has_trigger') && $attr->has_trigger; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$attr->can("has_trigger") and $attr->has_trigger
MC/DC100%2/2
$attr->can("has_trigger") and $attr->has_trigger
$attr->can("has_trigger")
$attr->has_trigger
Truth table100%3/3
A and B
A= $attr->can("has_trigger")B= $attr->has_trigger
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 51 | my $init_arg = $attr->init_arg; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 51 | ▶ | next unless defined $init_arg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 51 | ▶ | next unless exists $params->{$init_arg}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | $attr->trigger->( | ||||||||||||||||||||||||||||||||||||||||||
| 296 | $object, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 298 | $attr->should_coerce | ||||||||||||||||||||||||||||||||||||||||||
| 299 | ? $attr->get_read_method_ref->($object) | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 18 | ▶ | : $params->{$init_arg} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 302 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 761 | ▶ | sub _generate_fallback_constructor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_fallback_constructor: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 761 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 308 | 761 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 761 | return $class . '->Moose::Object::new(@_)' | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 761 | ▶ | sub _inline_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 761 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 761 | my ($params, $class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 315 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 761 | 'my ' . $params . ' = ', | |||||||||||||||||||||||||||||||||||||||||
| 317 | $self->_inline_BUILDARGS($class, '@_'), | ||||||||||||||||||||||||||||||||||||||||||
| 318 | ';', | ||||||||||||||||||||||||||||||||||||||||||
| 319 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 761 | ▶ | sub _inline_BUILDARGS { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_BUILDARGS: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 761 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 761 | my ($class, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 761 | my $buildargs = $self->find_method_by_name("BUILDARGS"); | |||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 761 | ▶ | if ($args eq '@_' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$args eq "\@_" and !$buildargs || $buildargs->body == \&Moose::Object::BUILDARGS
not $buildargs or $buildargs->body == \&Moose::Object::BUILDARGS
MC/DC66%2/3
$args eq "\@_" and !$buildargs || $buildargs->body == \&Moose::Object::BUILDARGS
$args eq "\@_"
not $buildargs
$buildargs->body == \&Moose::Object::BUILDARGS
Truth table75%3/4
A and not(B) or C
A= $args eq "\@_"B= not $buildargsC= $buildargs->body == \&Moose::Object::BUILDARGS
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) { | ||||||||||||||||||||||||||||||||||||||||||
| 330 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 759 | 'do {', | |||||||||||||||||||||||||||||||||||||||||
| 332 | 'my $params;', | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 'if (scalar @_ == 1) {', | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {', | ||||||||||||||||||||||||||||||||||||||||||
| 335 | $self->_inline_throw_exception( | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 'SingleParamsToNewMustBeHashRef' | ||||||||||||||||||||||||||||||||||||||||||
| 337 | ) . ';', | ||||||||||||||||||||||||||||||||||||||||||
| 338 | '}', | ||||||||||||||||||||||||||||||||||||||||||
| 339 | '$params = { %{ $_[0] } };', | ||||||||||||||||||||||||||||||||||||||||||
| 340 | '}', | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 'elsif (@_ % 2) {', | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 'Carp::carp(', | ||||||||||||||||||||||||||||||||||||||||||
| 343 | '"The new() method for ' . $class . ' expects a ' | ||||||||||||||||||||||||||||||||||||||||||
| 344 | . 'hash reference or a key/value list. You passed an ' | ||||||||||||||||||||||||||||||||||||||||||
| 345 | . 'odd number of arguments"', | ||||||||||||||||||||||||||||||||||||||||||
| 346 | ');', | ||||||||||||||||||||||||||||||||||||||||||
| 347 | '$params = {@_, undef};', | ||||||||||||||||||||||||||||||||||||||||||
| 348 | '}', | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 'else {', | ||||||||||||||||||||||||||||||||||||||||||
| 350 | '$params = {@_};', | ||||||||||||||||||||||||||||||||||||||||||
| 351 | '}', | ||||||||||||||||||||||||||||||||||||||||||
| 352 | '$params;', | ||||||||||||||||||||||||||||||||||||||||||
| 353 | '}', | ||||||||||||||||||||||||||||||||||||||||||
| 354 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 2 | return $class . '->BUILDARGS(' . $args . ')'; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 2496 | ▶ | sub _inline_slot_initializer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_slot_initializer: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 2496 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 363 | 2496 | my ($attr, $idx) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 2496 | '## ' . $attr->name, | |||||||||||||||||||||||||||||||||||||||||
| 367 | $self->_inline_check_required_attr($attr), | ||||||||||||||||||||||||||||||||||||||||||
| 368 | $self->SUPER::_inline_slot_initializer(@_), | ||||||||||||||||||||||||||||||||||||||||||
| 369 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 2495 | ▶ | sub _inline_check_required_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_check_required_attr: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 2495 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 374 | 2495 | my ($attr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 2495 | ▶ | return unless defined $attr->init_arg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 2486 | ▶ | return unless $attr->can('is_required') && $attr->is_required; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$attr->can("is_required") and $attr->is_required
MC/DC100%2/2
$attr->can("is_required") and $attr->is_required
$attr->can("is_required")
$attr->is_required
Truth table100%3/3
A and B
A= $attr->can("is_required")B= $attr->is_required
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 936 | ▶ | return if $attr->has_default || $attr->has_builder; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$attr->has_default or $attr->has_builder
MC/DC100%2/2
$attr->has_default or $attr->has_builder
$attr->has_default
$attr->has_builder
Truth table100%3/3
A or B
A= $attr->has_defaultB= $attr->has_builder
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 923 | my $throw = $self->_inline_throw_exception( | |||||||||||||||||||||||||||||||||||||||||
| 381 | 'AttributeIsRequired', | ||||||||||||||||||||||||||||||||||||||||||
| 382 | sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 383 | <<'EOF', quotemeta( $attr->name ), quotemeta( $attr->init_arg ) ), ); | ||||||||||||||||||||||||||||||||||||||||||
| 384 | params => $params, | ||||||||||||||||||||||||||||||||||||||||||
| 385 | class_name => $class_name, | ||||||||||||||||||||||||||||||||||||||||||
| 386 | attribute_name => "%s", | ||||||||||||||||||||||||||||||||||||||||||
| 387 | attribute_init_arg => "%s", | ||||||||||||||||||||||||||||||||||||||||||
| 388 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 923 | return sprintf( <<'EOF', quotemeta( $attr->init_arg ), $throw ) | |||||||||||||||||||||||||||||||||||||||||
| 391 | if ( !exists $params->{"%s"} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 392 | %s; | ||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | # XXX: these two are duplicated from cmop, because we have to pass the tc stuff | ||||||||||||||||||||||||||||||||||||||||||
| 398 | # through to _inline_set_value - this should probably be fixed, but i'm not | ||||||||||||||||||||||||||||||||||||||||||
| 399 | # quite sure how. -doy | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 2487 | ▶ | sub _inline_init_attr_from_constructor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_init_attr_from_constructor: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 2487 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 402 | 2487 | my ($attr, $idx) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 2487 | my @initial_value = $attr->_inline_set_value( | |||||||||||||||||||||||||||||||||||||||||
| 405 | '$instance', | ||||||||||||||||||||||||||||||||||||||||||
| 406 | '$params->{\'' . $attr->init_arg . '\'}', | ||||||||||||||||||||||||||||||||||||||||||
| 407 | '$type_constraint_bodies[' . $idx . ']', | ||||||||||||||||||||||||||||||||||||||||||
| 408 | '$type_coercions[' . $idx . ']', | ||||||||||||||||||||||||||||||||||||||||||
| 409 | '$type_constraint_messages[' . $idx . ']', | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 'for constructor', | ||||||||||||||||||||||||||||||||||||||||||
| 411 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 2487 | ▶ | push @initial_value, ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||||||||||||||||||||||||||||||||||||||||
| 415 | '$instance,', | ||||||||||||||||||||||||||||||||||||||||||
| 416 | $attr->_inline_instance_get('$instance'), | ||||||||||||||||||||||||||||||||||||||||||
| 417 | ');', | ||||||||||||||||||||||||||||||||||||||||||
| 418 | ) if $attr->has_initializer; | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 2487 | return @initial_value; | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 2496 | ▶ | sub _inline_init_attr_from_default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_init_attr_from_default: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 2496 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 2496 | my ($attr, $idx) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 2496 | ▶ | return if $attr->can('is_lazy') && $attr->is_lazy; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$attr->can("is_lazy") and $attr->is_lazy
MC/DC100%2/2
$attr->can("is_lazy") and $attr->is_lazy
$attr->can("is_lazy")
$attr->is_lazy
Truth table100%3/3
A and B
A= $attr->can("is_lazy")B= $attr->is_lazy
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 1221 | my $default = $self->_inline_default_value($attr, $idx); | |||||||||||||||||||||||||||||||||||||||||
| 429 | 1221 | ▶ | return unless $default; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | 141 | my @initial_value = ( | |||||||||||||||||||||||||||||||||||||||||
| 432 | 'my $default = ' . $default . ';', | ||||||||||||||||||||||||||||||||||||||||||
| 433 | $attr->_inline_set_value( | ||||||||||||||||||||||||||||||||||||||||||
| 434 | '$instance', | ||||||||||||||||||||||||||||||||||||||||||
| 435 | '$default', | ||||||||||||||||||||||||||||||||||||||||||
| 436 | '$type_constraint_bodies[' . $idx . ']', | ||||||||||||||||||||||||||||||||||||||||||
| 437 | '$type_coercions[' . $idx . ']', | ||||||||||||||||||||||||||||||||||||||||||
| 438 | '$type_constraint_messages[' . $idx . ']', | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 'for constructor', | ||||||||||||||||||||||||||||||||||||||||||
| 440 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 441 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 141 | ▶ | push @initial_value, ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||||||||||||||||||||||||||||||||||||||||
| 445 | '$instance,', | ||||||||||||||||||||||||||||||||||||||||||
| 446 | $attr->_inline_instance_get('$instance'), | ||||||||||||||||||||||||||||||||||||||||||
| 447 | ');', | ||||||||||||||||||||||||||||||||||||||||||
| 448 | ) if $attr->has_initializer; | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | 141 | return @initial_value; | |||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 761 | ▶ | sub _inline_extra_init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_extra_init: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 761 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 455 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 456 | 761 | $self->_inline_triggers, | |||||||||||||||||||||||||||||||||||||||||
| 457 | $self->_inline_BUILDALL, | ||||||||||||||||||||||||||||||||||||||||||
| 458 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 761 | ▶ | sub _inline_triggers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_triggers: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 761 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 761 | my @trigger_calls; | |||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 761 | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; | |||||||||||||||||||||||||||||||||||||||||
| 466 | 761 | for my $i (0 .. $#attrs) { | |||||||||||||||||||||||||||||||||||||||||
| 467 | 2496 | my $attr = $attrs[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 2496 | ▶ | next unless $attr->can('has_trigger') && $attr->has_trigger; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$attr->can("has_trigger") and $attr->has_trigger
MC/DC100%2/2
$attr->can("has_trigger") and $attr->has_trigger
$attr->can("has_trigger")
$attr->has_trigger
Truth table100%3/3
A and B
A= $attr->can("has_trigger")B= $attr->has_trigger
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 13 | my $init_arg = $attr->init_arg; | |||||||||||||||||||||||||||||||||||||||||
| 472 | 13 | ▶ | next unless defined $init_arg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 13 | push @trigger_calls, | |||||||||||||||||||||||||||||||||||||||||
| 475 | 'if (exists $params->{\'' . $init_arg . '\'}) {', | ||||||||||||||||||||||||||||||||||||||||||
| 476 | '$triggers->[' . $i . ']->(', | ||||||||||||||||||||||||||||||||||||||||||
| 477 | '$instance,', | ||||||||||||||||||||||||||||||||||||||||||
| 478 | $attr->_inline_instance_get('$instance') . ',', | ||||||||||||||||||||||||||||||||||||||||||
| 479 | ');', | ||||||||||||||||||||||||||||||||||||||||||
| 480 | '}'; | ||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 761 | return @trigger_calls; | |||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | 761 | ▶ | sub _inline_BUILDALL { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_BUILDALL: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 761 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 761 | my @methods = reverse $self->find_all_methods_by_name('BUILD'); | |||||||||||||||||||||||||||||||||||||||||
| 490 | 761 | ▶ | return () unless @methods; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | 623 | my @BUILD_calls; | |||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | 623 | foreach my $method (@methods) { | |||||||||||||||||||||||||||||||||||||||||
| 495 | push @BUILD_calls, | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 636 | '$instance->' . $method->{class} . '::BUILD($params);'; | |||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 500 | 623 | 'if (!$params->{__no_BUILD__}) {', | |||||||||||||||||||||||||||||||||||||||||
| 501 | @BUILD_calls, | ||||||||||||||||||||||||||||||||||||||||||
| 502 | '}', | ||||||||||||||||||||||||||||||||||||||||||
| 503 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 762 | ▶ | sub _eval_environment { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eval_environment: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 762 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 762 | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; | |||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | my $triggers = [ | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 762 | ▶ | map { $_->can('has_trigger') && $_->has_trigger ? $_->trigger : undef } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_->can("has_trigger") and $_->has_trigger
MC/DC100%2/2
$_->can("has_trigger") and $_->has_trigger
$_->can("has_trigger")
$_->has_trigger
Truth table100%3/3
A and B
A= $_->can("has_trigger")B= $_->has_trigger
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | @attrs | ||||||||||||||||||||||||||||||||||||||||||
| 514 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | # We need to check if the attribute ->can('type_constraint') | ||||||||||||||||||||||||||||||||||||||||||
| 517 | # since we may be trying to immutabilize a Moose meta class, | ||||||||||||||||||||||||||||||||||||||||||
| 518 | # which in turn has attributes which are Class::MOP::Attribute | ||||||||||||||||||||||||||||||||||||||||||
| 519 | # objects, rather than Moose::Meta::Attribute. And | ||||||||||||||||||||||||||||||||||||||||||
| 520 | # Class::MOP::Attribute attributes have no type constraints. | ||||||||||||||||||||||||||||||||||||||||||
| 521 | # However we need to make sure we leave an undef value there | ||||||||||||||||||||||||||||||||||||||||||
| 522 | # because the inlined code is using the index of the attributes | ||||||||||||||||||||||||||||||||||||||||||
| 523 | # to determine where to find the type constraint | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | my @type_constraints = map { | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 762 | ▶ | $_->can('type_constraint') ? $_->type_constraint : undef | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | } @attrs; | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | my @type_constraint_bodies = map { | ||||||||||||||||||||||||||||||||||||||||||
| 530 | 762 | ▶ | defined $_ ? $_->_compiled_type_constraint : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | } @type_constraints; | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | my @type_coercions = map { | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 762 | ▶ | defined $_ && $_->has_coercion | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $_ and $_->has_coercion
MC/DC100%2/2
defined $_ and $_->has_coercion
defined $_
$_->has_coercion
Truth table100%3/3
A and B
A= defined $_B= $_->has_coercion
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | ? $_->coercion->_compiled_type_coercion | ||||||||||||||||||||||||||||||||||||||||||
| 536 | : undef | ||||||||||||||||||||||||||||||||||||||||||
| 537 | } @type_constraints; | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | my @type_constraint_messages = map { | ||||||||||||||||||||||||||||||||||||||||||
| 540 | 762 | ▶ | defined $_ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | ? ($_->has_message ? $_->message : $_->_default_message) | ||||||||||||||||||||||||||||||||||||||||||
| 542 | : undef | ||||||||||||||||||||||||||||||||||||||||||
| 543 | } @type_constraints; | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 546 | 762 | ▶ | %{ $self->SUPER::_eval_environment }, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | 2495 | ▶ | ((any { defined && $_->has_initializer } @attrs) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 548 | ? ('$attrs' => \[@attrs]) | ||||||||||||||||||||||||||||||||||||||||||
| 549 | : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 550 | '$triggers' => \$triggers, | ||||||||||||||||||||||||||||||||||||||||||
| 551 | '@type_coercions' => \@type_coercions, | ||||||||||||||||||||||||||||||||||||||||||
| 552 | '@type_constraint_bodies' => \@type_constraint_bodies, | ||||||||||||||||||||||||||||||||||||||||||
| 553 | '@type_constraint_messages' => \@type_constraint_messages, | ||||||||||||||||||||||||||||||||||||||||||
| 554 | 762 | ▶ | ( map { defined($_) ? %{ $_->inline_environment } : () } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | @type_constraints ), | ||||||||||||||||||||||||||||||||||||||||||
| 556 | # pretty sure this is only going to be closed over if you use a custom | ||||||||||||||||||||||||||||||||||||||||||
| 557 | # error class at this point, but we should still get rid of this | ||||||||||||||||||||||||||||||||||||||||||
| 558 | # at some point | ||||||||||||||||||||||||||||||||||||||||||
| 559 | '$meta' => \$self, | ||||||||||||||||||||||||||||||||||||||||||
| 560 | '$class_name' => \($self->name), | ||||||||||||||||||||||||||||||||||||||||||
| 561 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||
| 564 | 15494 | ▶ | sub superclasses { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
superclasses: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 15494 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 566 | 15494 | my $supers = Data::OptList::mkopt(\@_); | |||||||||||||||||||||||||||||||||||||||||
| 567 | 15494 | foreach my $super (@{ $supers }) { | |||||||||||||||||||||||||||||||||||||||||
| 568 | 3136 | my ($name, $opts) = @{ $super }; | |||||||||||||||||||||||||||||||||||||||||
| 569 | 3136 | Moose::Util::_load_user_class($name, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 570 | 3135 | my $meta = Class::MOP::class_of($name); | |||||||||||||||||||||||||||||||||||||||||
| 571 | 3135 | ▶ | throw_exception( CanExtendOnlyClasses => role_name => $meta->name ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$meta and $meta->isa("Moose::Meta::Role")
MC/DC100%2/2
$meta and $meta->isa("Moose::Meta::Role")
$meta
$meta->isa("Moose::Meta::Role")
Truth table100%3/3
A and B
A= $metaB= $meta->isa("Moose::Meta::Role")
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | if $meta && $meta->isa('Moose::Meta::Role') | ||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | 15491 | return $self->SUPER::superclasses(map { $_->[0] } @{ $supers }); | |||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | ### --------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | 2346 | ▶ | sub add_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_attribute: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 580 | 2346 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 581 | 2346 | ▶ | my $attr = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($_[0]) and $_[0]->isa("Class::MOP::Attribute")
MC/DC50%1/2
builtin::blessed($_[0]) and $_[0]->isa("Class::MOP::Attribute")
builtin::blessed($_[0])
$_[0]->isa("Class::MOP::Attribute")
Truth table66%2/3
A and B
A= builtin::blessed($_[0])B= $_[0]->isa("Class::MOP::Attribute")
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute') | ||||||||||||||||||||||||||||||||||||||||||
| 583 | ? $_[0] | ||||||||||||||||||||||||||||||||||||||||||
| 584 | : $self->_process_attribute(@_)); | ||||||||||||||||||||||||||||||||||||||||||
| 585 | 2306 | $self->SUPER::add_attribute($attr); | |||||||||||||||||||||||||||||||||||||||||
| 586 | # it may be a Class::MOP::Attribute, theoretically, which doesn't have | ||||||||||||||||||||||||||||||||||||||||||
| 587 | # 'bare' and doesn't implement this method | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 2284 | ▶ | if ($attr->can('_check_associated_methods')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | 2281 | $attr->_check_associated_methods; | |||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 2284 | return $attr; | |||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | 1014 | ▶ | sub add_override_method_modifier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_override_method_modifier: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | 1014 | my ($self, $name, $method, $_super_package) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | 1014 | my $existing_method = $self->get_method($name); | |||||||||||||||||||||||||||||||||||||||||
| 598 | 1014 | ▶ | (!$existing_method) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | || throw_exception( CannotOverrideLocalMethodIsPresent => class_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||
| 600 | method => $existing_method, | ||||||||||||||||||||||||||||||||||||||||||
| 601 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 1012 | $self->add_method($name => Moose::Meta::Method::Overridden->new( | |||||||||||||||||||||||||||||||||||||||||
| 603 | method => $method, | ||||||||||||||||||||||||||||||||||||||||||
| 604 | class => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 605 | package => $_super_package, # need this for roles | ||||||||||||||||||||||||||||||||||||||||||
| 606 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 607 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 16 | ▶ | sub add_augment_method_modifier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_augment_method_modifier: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | 16 | my ($self, $name, $method) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 612 | 16 | my $existing_method = $self->get_method($name); | |||||||||||||||||||||||||||||||||||||||||
| 613 | 16 | ▶ | throw_exception( CannotAugmentIfLocalMethodPresent => class_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 614 | method => $existing_method, | ||||||||||||||||||||||||||||||||||||||||||
| 615 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 616 | if( $existing_method ); | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | 14 | $self->add_method($name => Moose::Meta::Method::Augmented->new( | |||||||||||||||||||||||||||||||||||||||||
| 619 | method => $method, | ||||||||||||||||||||||||||||||||||||||||||
| 620 | class => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 621 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 622 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | ## Private Utility methods ... | ||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | 1 | ▶ | sub _find_next_method_by_name_which_is_not_overridden { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_next_method_by_name_which_is_not_overridden: called CC=4 SCAR=14.3
| |||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 629 | 1 | foreach my $method ($self->find_all_methods_by_name($name)) { | |||||||||||||||||||||||||||||||||||||||||
| 630 | return $method->{code} | ||||||||||||||||||||||||||||||||||||||||||
| 631 | 2 | ▶ | if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($method->{"code"}) and not $method->{"code"}->isa("Moose::Meta::Method::Overridden")
MC/DC50%1/2
builtin::blessed($method->{"code"}) and not $method->{"code"}->isa("Moose::Meta::Method::Overridden")
builtin::blessed($method->{"code"})
not $method->{"code"}->isa("Moose::Meta::Method::Overridden")
Truth table66%2/3
A and not(B)
A= builtin::blessed($method->{"code"})B= not $method->{"code"}->isa("Moose::Meta::Method::Overridden")
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | ## Metaclass compatibility | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 6174 | ▶ | sub _base_metaclasses { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_base_metaclasses: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | 6174 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 640 | 6174 | my %metaclasses = $self->SUPER::_base_metaclasses; | |||||||||||||||||||||||||||||||||||||||||
| 641 | 6174 | for my $class (keys %metaclasses) { | |||||||||||||||||||||||||||||||||||||||||
| 642 | 37044 | $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/; | |||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 644 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 645 | 6174 | %metaclasses, | |||||||||||||||||||||||||||||||||||||||||
| 646 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | 38 | ▶ | sub _fix_class_metaclass_incompatibility { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fix_class_metaclass_incompatibility: called CC=3 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | 38 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 651 | 38 | my ($super_meta) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||
| 653 | 38 | $self->SUPER::_fix_class_metaclass_incompatibility(@_); | |||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||
| 655 | 35 | ▶ | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | ($self->is_pristine) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 657 | || throw_exception( CannotFixMetaclassCompatibility => class => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 658 | superclass => $super_meta | ||||||||||||||||||||||||||||||||||||||||||
| 659 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my $super_meta_name = $super_meta->_real_ref_name; | |||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name); | |||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | my $new_self = $class_meta_subclass_meta_name->reinitialize( | |||||||||||||||||||||||||||||||||||||||||
| 663 | $self->name, | ||||||||||||||||||||||||||||||||||||||||||
| 664 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | $self->_replace_self( $new_self, $class_meta_subclass_meta_name ); | |||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | 124 | ▶ | sub _fix_single_metaclass_incompatibility { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fix_single_metaclass_incompatibility: called CC=3 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 671 | 124 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 672 | 124 | my ($metaclass_type, $super_meta) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | 124 | $self->SUPER::_fix_single_metaclass_incompatibility(@_); | |||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | 124 | ▶ | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | ($self->is_pristine) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | || throw_exception( CannotFixMetaclassCompatibility => class => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 679 | superclass => $super_meta, | ||||||||||||||||||||||||||||||||||||||||||
| 680 | metaclass_type => $metaclass_type | ||||||||||||||||||||||||||||||||||||||||||
| 681 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my $super_meta_name = $super_meta->_real_ref_name; | |||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type); | |||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $new_self = $super_meta->reinitialize( | |||||||||||||||||||||||||||||||||||||||||
| 685 | $self->name, | ||||||||||||||||||||||||||||||||||||||||||
| 686 | $metaclass_type => $class_specific_meta_subclass_meta_name, | ||||||||||||||||||||||||||||||||||||||||||
| 687 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $self->_replace_self( $new_self, $super_meta_name ); | |||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | sub _replace_self { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_replace_self: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my ( $new_self, $new_class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | %$self = %$new_self; | |||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | bless $self, $new_class; | |||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | # We need to replace the cached metaclass instance or else when it goes | ||||||||||||||||||||||||||||||||||||||||||
| 701 | # out of scope Class::MOP::Class destroy's the namespace for the | ||||||||||||||||||||||||||||||||||||||||||
| 702 | # metaclass's class, causing much havoc. | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | my $weaken = Class::MOP::metaclass_is_weak( $self->name ); | |||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | Class::MOP::store_metaclass_by_name( $self->name, $self ); | |||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | Class::MOP::weaken_metaclass( $self->name ) if $weaken; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | 1676 | ▶ | sub _process_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_attribute: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||
| 709 | 1676 | my ( $self, $name, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
scalar @args == 1 and ref $args[0] eq "HASH"
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "HASH"
scalar @args == 1
ref $args[0] eq "HASH"
Truth table33%1/3
A and B
A= scalar @args == 1B= ref $args[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | 1676 | ▶ | if (($name || '') =~ /^\+(.*)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$name || ''
MC/DC100%1/1
$name || ''
$name
Truth table100%2/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||
| 714 | 40 | return $self->_process_inherited_attribute($1, @args); | |||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||
| 716 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 717 | 1636 | return $self->_process_new_attribute($name, @args); | |||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | 1636 | ▶ | sub _process_new_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_new_attribute: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 722 | 1636 | my ( $self, $name, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | 1636 | $self->attribute_metaclass->interpolate_class_and_new($name, @args); | |||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | 40 | ▶ | sub _process_inherited_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_inherited_attribute: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 728 | 40 | my ($self, $attr_name, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | 40 | my $inherited_attr = $self->find_attribute_by_name($attr_name); | |||||||||||||||||||||||||||||||||||||||||
| 731 | 40 | ▶ | (defined $inherited_attr) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 732 | || throw_exception( NoAttributeFoundInSuperClass => class_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||
| 733 | attribute_name => $attr_name, | ||||||||||||||||||||||||||||||||||||||||||
| 734 | params => \%options | ||||||||||||||||||||||||||||||||||||||||||
| 735 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 736 | 36 | ▶ | if ($inherited_attr->isa('Moose::Meta::Attribute')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 737 | 36 | return $inherited_attr->clone_and_inherit_options(%options); | |||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||
| 739 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 740 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||
| 741 | # kind of a kludge to handle Class::MOP::Attributes | ||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options); | |||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | # reinitialization support | ||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | 104 | ▶ | sub _restore_metaobjects_from { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_restore_metaobjects_from: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 749 | 104 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 750 | 104 | my ($old_meta) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | 104 | $self->SUPER::_restore_metaobjects_from($old_meta); | |||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | 102 | for my $role ( @{ $old_meta->roles } ) { | |||||||||||||||||||||||||||||||||||||||||
| 755 | 8 | $self->add_role($role); | |||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||
| 758 | 102 | for my $application ( @{ $old_meta->_get_role_applications } ) { | |||||||||||||||||||||||||||||||||||||||||
| 759 | 8 | $application->class($self); | |||||||||||||||||||||||||||||||||||||||||
| 760 | 8 | $self->add_role_application ($application); | |||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | ## Immutability | ||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | 777 | ▶ | sub _immutable_options { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_immutable_options: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 767 | 777 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | 777 | $self->SUPER::_immutable_options( | |||||||||||||||||||||||||||||||||||||||||
| 770 | inline_destructor => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||
| 772 | # Moose always does this when an attribute is created | ||||||||||||||||||||||||||||||||||||||||||
| 773 | inline_accessors => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||
| 775 | @args, | ||||||||||||||||||||||||||||||||||||||||||
| 776 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | 83 | ▶ | sub _fixup_attributes_after_rebless { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fixup_attributes_after_rebless: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 780 | 83 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 781 | 83 | my ($instance, $rebless_from, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||
| 783 | 83 | $self->SUPER::_fixup_attributes_after_rebless( | |||||||||||||||||||||||||||||||||||||||||
| 784 | $instance, | ||||||||||||||||||||||||||||||||||||||||||
| 785 | $rebless_from, | ||||||||||||||||||||||||||||||||||||||||||
| 786 | %params | ||||||||||||||||||||||||||||||||||||||||||
| 787 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||
| 789 | 79 | $self->_call_all_triggers( $instance, \%params ); | |||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | ## ------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||
| 794 | 388 | our $error_level; | |||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||
| 796 | 1682 | ▶ | sub _inline_throw_exception { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_throw_exception: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 797 | 1682 | my ( $self, $exception_type, $throw_args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 798 | 1682 | ▶ | return 'die Module::Runtime::use_module("Moose::Exception::' . $exception_type . '")->new(' . ($throw_args || '') . ')'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$throw_args || ''
MC/DC100%1/1
$throw_args || ''
$throw_args
Truth table100%2/2
A
A= $throw_args
| |||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | 388 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||
| 803 | # ABSTRACT: The Moose metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | __END__ | ||||||||||||||||||||||||||||||||||||||||||