| 1 | package Moose::Meta::Role; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 386 | our $VERSION = '2.4001'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 386 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 386 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 386 | ▶ | use metaclass; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 386 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 386 | ▶ | use Moose::Meta::Class; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 386 | ▶ | use Moose::Meta::Role::Attribute; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 386 | ▶ | use Moose::Meta::Role::Method; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 386 | ▶ | use Moose::Meta::Role::Method::Required; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 386 | ▶ | use Moose::Meta::Role::Method::Conflicting; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 386 | ▶ | use Moose::Meta::Method::Meta; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 386 | ▶ | use Moose::Util qw/throw_exception/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 386 | ▶ | use Class::MOP::MiniTrait; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 386 | ▶ | use parent 'Class::MOP::Module', | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 'Class::MOP::Mixin::HasAttributes', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 'Class::MOP::Mixin::HasMethods', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 386 | 'Class::MOP::Mixin::HasOverloads'; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 386 | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | ## ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ## NOTE: | ||||||||||||||||||||||||||||||||||||||||||
| 28 | ## I normally don't do this, but I am doing | ||||||||||||||||||||||||||||||||||||||||||
| 29 | ## a whole bunch of meta-programmin' in this | ||||||||||||||||||||||||||||||||||||||||||
| 30 | ## module, so it just makes sense. For a clearer | ||||||||||||||||||||||||||||||||||||||||||
| 31 | ## picture of what is going on in the next | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ## several lines of code, look at the really | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ## big comment at the end of this file (right | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ## before the POD). | ||||||||||||||||||||||||||||||||||||||||||
| 35 | ## - SL | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ## ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 386 | my $META = __PACKAGE__->meta; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | ## ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ## attributes ... | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # since roles are lazy, we hold all the attributes | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # of the individual role in 'stasis' until which | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # time when it is applied to a class. This means | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # keeping a lot of things in hash maps, so we are | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # using a little of that meta-programmin' magic | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # here and saving lots of extra typin'. And since | ||||||||||||||||||||||||||||||||||||||||||
| 50 | # many of these attributes above require similar | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # functionality to support them, so we again use | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # the wonders of meta-programmin' to deliver a | ||||||||||||||||||||||||||||||||||||||||||
| 53 | # very compact solution to this normally verbose | ||||||||||||||||||||||||||||||||||||||||||
| 54 | # problem. | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # - SL | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 386 | foreach my $action ( | |||||||||||||||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | name => 'excluded_roles_map', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | attr_reader => 'get_excluded_roles_map' , | ||||||||||||||||||||||||||||||||||||||||||
| 61 | methods => { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | add => 'add_excluded_roles', | ||||||||||||||||||||||||||||||||||||||||||
| 63 | get_keys => 'get_excluded_roles_list', | ||||||||||||||||||||||||||||||||||||||||||
| 64 | existence => 'excludes_role', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | name => 'required_methods', | ||||||||||||||||||||||||||||||||||||||||||
| 69 | attr_reader => 'get_required_methods_map', | ||||||||||||||||||||||||||||||||||||||||||
| 70 | methods => { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | remove => 'remove_required_methods', | ||||||||||||||||||||||||||||||||||||||||||
| 72 | get_values => 'get_required_method_list', | ||||||||||||||||||||||||||||||||||||||||||
| 73 | existence => 'requires_method', | ||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 772 | my $attr_reader = $action->{attr_reader}; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 772 | my $methods = $action->{methods}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | # create the attribute | ||||||||||||||||||||||||||||||||||||||||||
| 82 | $META->add_attribute($action->{name} => ( | ||||||||||||||||||||||||||||||||||||||||||
| 83 | reader => $attr_reader, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 3144 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 772 | Class::MOP::_definition_context(), | |||||||||||||||||||||||||||||||||||||||||
| 86 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # create some helper methods | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 102 | ▶ | $META->add_method($methods->{add} => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Subroutine
add_excluded_roles: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 102 | my ($self, @values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 102 | $self->$attr_reader->{$_} = undef foreach @values; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 772 | ▶ | }) if exists $methods->{add}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 1650 | ▶ | $META->add_method($methods->{get_keys} => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_excluded_roles_list: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 1650 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 1650 | keys %{$self->$attr_reader}; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 772 | ▶ | }) if exists $methods->{get_keys}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 1407 | ▶ | $META->add_method($methods->{get_values} => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_required_method_list: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 1407 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 1407 | values %{$self->$attr_reader}; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 772 | ▶ | }) if exists $methods->{get_values}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $META->add_method($methods->{get} => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $self->$attr_reader->{$name} | |||||||||||||||||||||||||||||||||||||||||
| 107 | 772 | ▶ | }) if exists $methods->{get}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 651 | ▶ | $META->add_method($methods->{existence} => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
requires_method: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 651 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 651 | ▶ | exists $self->$attr_reader->{$name} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 772 | ▶ | }) if exists $methods->{existence}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $META->add_method($methods->{remove} => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my ($self, @values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | delete $self->$attr_reader->{$_} foreach @values; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 772 | ▶ | }) if exists $methods->{remove}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | $META->add_attribute( | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 386 | 'method_metaclass', | |||||||||||||||||||||||||||||||||||||||||
| 122 | reader => 'method_metaclass', | ||||||||||||||||||||||||||||||||||||||||||
| 123 | default => 'Moose::Meta::Role::Method', | ||||||||||||||||||||||||||||||||||||||||||
| 124 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 386 | $META->add_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 128 | 'required_method_metaclass', | ||||||||||||||||||||||||||||||||||||||||||
| 129 | reader => 'required_method_metaclass', | ||||||||||||||||||||||||||||||||||||||||||
| 130 | default => 'Moose::Meta::Role::Method::Required', | ||||||||||||||||||||||||||||||||||||||||||
| 131 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 132 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 386 | $META->add_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 135 | 'conflicting_method_metaclass', | ||||||||||||||||||||||||||||||||||||||||||
| 136 | reader => 'conflicting_method_metaclass', | ||||||||||||||||||||||||||||||||||||||||||
| 137 | default => 'Moose::Meta::Role::Method::Conflicting', | ||||||||||||||||||||||||||||||||||||||||||
| 138 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 139 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 386 | $META->add_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 142 | 'application_to_class_class', | ||||||||||||||||||||||||||||||||||||||||||
| 143 | reader => 'application_to_class_class', | ||||||||||||||||||||||||||||||||||||||||||
| 144 | default => 'Moose::Meta::Role::Application::ToClass', | ||||||||||||||||||||||||||||||||||||||||||
| 145 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 146 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 386 | $META->add_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 149 | 'application_to_role_class', | ||||||||||||||||||||||||||||||||||||||||||
| 150 | reader => 'application_to_role_class', | ||||||||||||||||||||||||||||||||||||||||||
| 151 | default => 'Moose::Meta::Role::Application::ToRole', | ||||||||||||||||||||||||||||||||||||||||||
| 152 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 153 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 386 | $META->add_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 156 | 'application_to_instance_class', | ||||||||||||||||||||||||||||||||||||||||||
| 157 | reader => 'application_to_instance_class', | ||||||||||||||||||||||||||||||||||||||||||
| 158 | default => 'Moose::Meta::Role::Application::ToInstance', | ||||||||||||||||||||||||||||||||||||||||||
| 159 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 160 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 386 | $META->add_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 163 | 'applied_attribute_metaclass', | ||||||||||||||||||||||||||||||||||||||||||
| 164 | reader => 'applied_attribute_metaclass', | ||||||||||||||||||||||||||||||||||||||||||
| 165 | default => 'Moose::Meta::Attribute', | ||||||||||||||||||||||||||||||||||||||||||
| 166 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | # More or less copied from Moose::Meta::Class | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 1314 | ▶ | sub initialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 1314 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 1314 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 1314 | ▶ | unshift @args, 'package' if @args % 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 1314 | my %opts = @args; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 1314 | my $package = delete $opts{package}; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 1314 | ▶ | return Class::MOP::get_metaclass_by_name($package) | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
Class::MOP::get_metaclass_by_name($package) || $class->SUPER::initialize($package, 'attribute_metaclass', 'Moose::Meta::Role::Attribute', %opts)
MC/DC0%0/2
Class::MOP::get_metaclass_by_name($package) || $class->SUPER::initialize($package, 'attribute_metaclass', 'Moose::Meta::Role::Attribute', %opts)
Class::MOP::get_metaclass_by_name($package)
$class->SUPER::initialize($package, 'attribute_metaclass', 'Moose::Meta::Role::Attribute', %opts)
Truth table33%1/3
A || B
A= Class::MOP::get_metaclass_by_name($package)B= $class->SUPER::initialize($package, 'attribute_metaclass', 'Moose::Meta::Role::Attribute', %opts)
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | || $class->SUPER::initialize($package, | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 'attribute_metaclass' => 'Moose::Meta::Role::Attribute', | ||||||||||||||||||||||||||||||||||||||||||
| 179 | %opts, | ||||||||||||||||||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 17 | ▶ | sub reinitialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reinitialize: called CC=8 SCAR=22.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 17 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 17 | ▶ | my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 17 | my %existing_classes; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 17 | ▶ | if ($meta) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 17 | %existing_classes = map { $_ => $meta->$_() } qw( | |||||||||||||||||||||||||||||||||||||||||
| 192 | attribute_metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 193 | method_metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 194 | wrapped_method_metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 195 | required_method_metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 196 | conflicting_method_metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 197 | application_to_class_class | ||||||||||||||||||||||||||||||||||||||||||
| 198 | application_to_role_class | ||||||||||||||||||||||||||||||||||||||||||
| 199 | application_to_instance_class | ||||||||||||||||||||||||||||||||||||||||||
| 200 | applied_attribute_metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 17 | my %options = @_; | |||||||||||||||||||||||||||||||||||||||||
| 205 | $options{weaken} = Class::MOP::metaclass_is_weak($meta->name) | ||||||||||||||||||||||||||||||||||||||||||
| 206 | if !exists $options{weaken} | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 17 | ▶ | && blessed($meta) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not exists $options{"weaken"} and builtin::blessed($meta) and $meta->isa("Moose::Meta::Role")
not exists $options{"weaken"} and builtin::blessed($meta)
MC/DC0%0/3
not exists $options{"weaken"} and builtin::blessed($meta) and $meta->isa("Moose::Meta::Role")
not exists $options{"weaken"}
builtin::blessed($meta)
$meta->isa("Moose::Meta::Role")
Truth table25%1/4
not(A) and B and C
A= not exists $options{"weaken"}B= builtin::blessed($meta)C= $meta->isa("Moose::Meta::Role")
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | && $meta->isa('Moose::Meta::Role'); | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | # don't need to remove generated metaobjects here yet, since we don't | ||||||||||||||||||||||||||||||||||||||||||
| 211 | # yet generate anything in roles. this may change in the future though... | ||||||||||||||||||||||||||||||||||||||||||
| 212 | # keep an eye on that | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 17 | my $new_meta = $self->SUPER::reinitialize( | |||||||||||||||||||||||||||||||||||||||||
| 214 | $pkg, | ||||||||||||||||||||||||||||||||||||||||||
| 215 | %existing_classes, | ||||||||||||||||||||||||||||||||||||||||||
| 216 | %options, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 17 | ▶ | $new_meta->_restore_metaobjects_from($meta) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$meta and $meta->isa("Moose::Meta::Role")
MC/DC0%0/2
$meta and $meta->isa("Moose::Meta::Role")
$meta
$meta->isa("Moose::Meta::Role")
Truth table33%1/3
A and B
A= $metaB= $meta->isa("Moose::Meta::Role")
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | if $meta && $meta->isa('Moose::Meta::Role'); | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 17 | return $new_meta; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 17 | ▶ | sub _restore_metaobjects_from { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_restore_metaobjects_from: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 17 | my ($old_meta) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 17 | $self->_restore_metamethods_from($old_meta); | |||||||||||||||||||||||||||||||||||||||||
| 228 | 17 | $self->_restore_metaattributes_from($old_meta); | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 17 | for my $role ( @{ $old_meta->get_roles } ) { | |||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | $self->add_role($role); | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 727 | ▶ | sub add_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_attribute: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 727 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 727 | ▶ | if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
builtin::blessed($_[0]) and not $_[0]->isa("Moose::Meta::Role::Attribute")
MC/DC100%2/2
builtin::blessed($_[0]) and not $_[0]->isa("Moose::Meta::Role::Attribute")
builtin::blessed($_[0])
not $_[0]->isa("Moose::Meta::Role::Attribute")
Truth table100%3/3
A and not(B)
A= builtin::blessed($_[0])B= not $_[0]->isa("Moose::Meta::Role::Attribute")
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | my $class = ref $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | throw_exception( CannotAddAsAnAttributeToARole => role_name => $self->name, | |||||||||||||||||||||||||||||||||||||||||
| 241 | attribute_class => $class, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | ▶ | elsif (!blessed($_[0]) && defined($_[0]) && $_[0] =~ /^\+(.*)/) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
not builtin::blessed($_[0]) and defined $_[0] and $_[0] =~ /^\+(.*)/
not builtin::blessed($_[0]) and defined $_[0]
MC/DC100%3/3
not builtin::blessed($_[0]) and defined $_[0] and $_[0] =~ /^\+(.*)/
not builtin::blessed($_[0])
defined $_[0]
$_[0] =~ /^\+(.*)/
Truth table100%4/4
not(A) and B and C
A= not builtin::blessed($_[0])B= defined $_[0]C= $_[0] =~ /^\+(.*)/
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | throw_exception( AttributeExtensionIsNotSupportedInRoles => attribute_name => $_[0], | |||||||||||||||||||||||||||||||||||||||||
| 246 | role_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||
| 247 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 724 | return $self->SUPER::add_attribute(@_); | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 722 | ▶ | sub _attach_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attach_attribute: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 722 | my ( $self, $attribute ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 722 | $attribute->attach_to_role($self); | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 692 | ▶ | sub add_required_methods { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_required_methods: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 692 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 692 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 263 | 577 | my $method = $_; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 577 | ▶ | if (!blessed($method)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 185 | $method = $self->required_method_metaclass->new( | |||||||||||||||||||||||||||||||||||||||||
| 266 | name => $method, | ||||||||||||||||||||||||||||||||||||||||||
| 267 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 577 | $self->get_required_methods_map->{$method->name} = $method; | |||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 135 | ▶ | sub add_conflicting_method { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_conflicting_method: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 135 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 135 | my $method; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 135 | ▶ | if (@_ == 1 && blessed($_[0])) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and builtin::blessed($_[0])
MC/DC0%0/2
@_ == 1 and builtin::blessed($_[0])
@_ == 1
builtin::blessed($_[0])
Truth table33%1/3
A and B
A= @_ == 1B= builtin::blessed($_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $method = shift; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 135 | $method = $self->conflicting_method_metaclass->new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 135 | $self->add_required_methods($method); | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | ## ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 288 | ## method modifiers | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||
| 291 | # the before/around/after method modifiers are | ||||||||||||||||||||||||||||||||||||||||||
| 292 | # stored by name, but there can be many methods | ||||||||||||||||||||||||||||||||||||||||||
| 293 | # then associated with that name. So again we have | ||||||||||||||||||||||||||||||||||||||||||
| 294 | # lots of similar functionality, so we can do some | ||||||||||||||||||||||||||||||||||||||||||
| 295 | # meta-programmin' and save some time. | ||||||||||||||||||||||||||||||||||||||||||
| 296 | # - SL | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 386 | foreach my $modifier_type (qw[ before around after ]) { | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 1158 | my $attr_reader = "get_${modifier_type}_method_modifiers_map"; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | # create the attribute ... | ||||||||||||||||||||||||||||||||||||||||||
| 303 | $META->add_attribute("${modifier_type}_method_modifiers" => ( | ||||||||||||||||||||||||||||||||||||||||||
| 304 | reader => $attr_reader, | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 4716 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 1158 | Class::MOP::_definition_context(), | |||||||||||||||||||||||||||||||||||||||||
| 307 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | # and some helper methods ... | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 1756 | ▶ | $META->add_method("get_${modifier_type}_method_modifiers" => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_after_method_modifiers: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 1756 | my ($self, $method_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 312 | #return () unless exists $self->$attr_reader->{$method_name}; | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 1756 | my $mm = $self->$attr_reader->{$method_name}; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 1756 | ▶ | $mm ? @$mm : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 1158 | }); | |||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 2 | ▶ | $META->add_method("has_${modifier_type}_method_modifiers" => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_before_method_modifiers: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 2 | my ($self, $method_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 319 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||
| 320 | # for now we assume that if it exists,.. | ||||||||||||||||||||||||||||||||||||||||||
| 321 | # it has at least one modifier in it | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | ▶ | (exists $self->$attr_reader->{$method_name}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 1158 | }); | |||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 917 | ▶ | $META->add_method("add_${modifier_type}_method_modifier" => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_after_method_modifier: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 917 | my ($self, $method_name, $method) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | $self->$attr_reader->{$method_name} = [] | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 917 | ▶ | unless exists $self->$attr_reader->{$method_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 917 | my $modifiers = $self->$attr_reader->{$method_name}; | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||
| 334 | # check to see that we aren't adding the | ||||||||||||||||||||||||||||||||||||||||||
| 335 | # same code twice. We err in favor of the | ||||||||||||||||||||||||||||||||||||||||||
| 336 | # first on here, this may not be as expected | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 917 | foreach my $modifier (@{$modifiers}) { | |||||||||||||||||||||||||||||||||||||||||
| 338 | 10 | ▶ | return if $modifier == $method; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 908 | push @{$modifiers} => $method; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 1158 | }); | |||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | ## ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 347 | ## override method modifiers | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | $META->add_attribute('override_method_modifiers' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 350 | reader => 'get_override_method_modifiers_map', | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 1572 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 386 | Class::MOP::_definition_context(), | |||||||||||||||||||||||||||||||||||||||||
| 353 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||
| 356 | # these are a little different because there | ||||||||||||||||||||||||||||||||||||||||||
| 357 | # can only be one per name, whereas the other | ||||||||||||||||||||||||||||||||||||||||||
| 358 | # method modifiers can have multiples. | ||||||||||||||||||||||||||||||||||||||||||
| 359 | # - SL | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 1453 | ▶ | sub add_override_method_modifier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_override_method_modifier: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 1453 | my ($self, $method_name, $method) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 363 | 1453 | ▶ | (!$self->has_method($method_name)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | || throw_exception( CannotOverrideALocalMethod => method_name => $method_name, | ||||||||||||||||||||||||||||||||||||||||||
| 365 | role_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||
| 366 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 1451 | $self->get_override_method_modifiers_map->{$method_name} = $method; | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 1051 | ▶ | sub has_override_method_modifier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_override_method_modifier: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 1051 | my ($self, $method_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 372 | # NOTE: | ||||||||||||||||||||||||||||||||||||||||||
| 373 | # for now we assume that if it exists,.. | ||||||||||||||||||||||||||||||||||||||||||
| 374 | # it has at least one modifier in it | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 1051 | ▶ | (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 2301 | ▶ | sub get_override_method_modifier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_override_method_modifier: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 2301 | my ($self, $method_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 2301 | $self->get_override_method_modifiers_map->{$method_name}; | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | ## general list accessor ... | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 8446 | ▶ | sub get_method_modifier_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_method_modifier_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 8446 | my ($self, $modifier_type) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 8446 | my $accessor = "get_${modifier_type}_method_modifiers_map"; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 8446 | keys %{$self->$accessor}; | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 1311 | ▶ | sub _meta_method_class { 'Moose::Meta::Method::Meta' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_meta_method_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | ## ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 394 | ## subroles | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | $META->add_attribute('roles' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 397 | reader => 'get_roles', | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 1314 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 386 | Class::MOP::_definition_context(), | |||||||||||||||||||||||||||||||||||||||||
| 400 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 499 | ▶ | sub add_role { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_role: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 499 | my ($self, $role) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 499 | ▶ | (blessed($role) && $role->isa('Moose::Meta::Role')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($role) and $role->isa("Moose::Meta::Role")
MC/DC50%1/2
builtin::blessed($role) and $role->isa("Moose::Meta::Role")
builtin::blessed($role)
$role->isa("Moose::Meta::Role")
Truth table66%2/3
A and B
A= builtin::blessed($role)B= $role->isa("Moose::Meta::Role")
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | || throw_exception( AddRoleToARoleTakesAMooseMetaRole => role_to_be_added => $role, | ||||||||||||||||||||||||||||||||||||||||||
| 406 | role_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||
| 407 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 498 | push @{$self->get_roles} => $role; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 498 | $self->reset_package_cache_flag; | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 541 | ▶ | sub calculate_all_roles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calculate_all_roles: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 541 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 414 | 541 | my %seen; | |||||||||||||||||||||||||||||||||||||||||
| 415 | grep { | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 756 | !$seen{$_->name}++ | |||||||||||||||||||||||||||||||||||||||||
| 417 | } ($self, map { | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 206 | $_->calculate_all_roles | |||||||||||||||||||||||||||||||||||||||||
| 419 | 541 | } @{ $self->get_roles }); | |||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 773 | ▶ | sub does_role { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
does_role: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | 773 | my ($self, $role) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 424 | 773 | ▶ | (defined $role) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | || throw_exception( RoleNameRequiredForMooseMetaRole => role_name => $self->name ); | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 772 | ▶ | my $role_name = blessed $role ? $role->name : $role; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | # if we are it,.. then return true | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 772 | ▶ | return 1 if $role_name eq $self->name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | # otherwise.. check our children | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 386 | foreach my $role (@{$self->get_roles}) { | |||||||||||||||||||||||||||||||||||||||||
| 431 | 272 | ▶ | return 1 if $role->does_role($role_name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 226 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 1949 | ▶ | sub find_method_by_name { (shift)->get_method(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_method_by_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | ## ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 439 | ## role construction | ||||||||||||||||||||||||||||||||||||||||||
| 440 | ## ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 1651 | ▶ | sub apply { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | 1651 | my ($self, $other, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 1651 | ▶ | (blessed($other)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | || throw_exception( ApplyTakesABlessedInstance => param => $other, | ||||||||||||||||||||||||||||||||||||||||||
| 447 | role_name => $self->name, | ||||||||||||||||||||||||||||||||||||||||||
| 448 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | 1650 | my $application_class; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 1650 | ▶ | if ($other->isa('Moose::Meta::Role')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 504 | $application_class = $self->application_to_role_class; | |||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||
| 454 | elsif ($other->isa('Moose::Meta::Class')) { | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 1123 | $application_class = $self->application_to_class_class; | |||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||
| 457 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 23 | $application_class = $self->application_to_instance_class; | |||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 1650 | Moose::Util::_load_user_class($application_class); | |||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | 1650 | ▶ | if ( exists $args{'-excludes'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | # I wish we had coercion here :) | ||||||||||||||||||||||||||||||||||||||||||
| 465 | $args{'-excludes'} = ( | ||||||||||||||||||||||||||||||||||||||||||
| 466 | ref $args{'-excludes'} eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||
| 467 | ? $args{'-excludes'} | ||||||||||||||||||||||||||||||||||||||||||
| 468 | 13 | ▶ | : [ $args{'-excludes'} ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 1650 | return $application_class->new(%args)->apply($self, $other, \%args); | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | 582 | ▶ | sub composition_class_roles { } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
composition_class_roles: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 231 | ▶ | sub combine { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
combine: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 231 | my ($class, @role_specs) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 231 | require Moose::Meta::Role::Composite; | |||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | 231 | my (@roles, %role_params); | |||||||||||||||||||||||||||||||||||||||||
| 483 | 231 | ▶ | while (@role_specs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 519 | my ($role, $params) = @{ splice @role_specs, 0, 1 }; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 519 | ▶ | my $requested_role | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | = blessed $role | ||||||||||||||||||||||||||||||||||||||||||
| 487 | ? $role | ||||||||||||||||||||||||||||||||||||||||||
| 488 | : Class::MOP::class_of($role); | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | 519 | my $actual_role = $requested_role->_role_for_combination($params); | |||||||||||||||||||||||||||||||||||||||||
| 491 | 519 | push @roles => $actual_role; | |||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 519 | ▶ | next unless defined $params; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | 29 | $role_params{$actual_role->name} = $params; | |||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 231 | my $c = Moose::Meta::Role::Composite->new(roles => \@roles); | |||||||||||||||||||||||||||||||||||||||||
| 498 | 231 | return $c->apply_params(\%role_params); | |||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 518 | ▶ | sub _role_for_combination { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_role_for_combination: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 518 | my ($self, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 518 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 16 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: called CC=16 SCAR=28.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 16 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 508 | 16 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | 16 | ▶ | unshift @args, 'package' if @args % 2 == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 16 | my %options = @args; | |||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | (ref $options{attributes} eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||
| 514 | || throw_exception( CreateTakesHashRefOfAttributes => params => \%options, | ||||||||||||||||||||||||||||||||||||||||||
| 515 | attribute_class => $class | ||||||||||||||||||||||||||||||||||||||||||
| 516 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 16 | ▶ | if exists $options{attributes}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
exists $options{'attributes'} && (ref $options{'attributes'} eq 'HASH' || throw_exception('CreateTakesHashRefOfAttributes', 'params', \%options, 'attribute_class', $class))
ref $options{"attributes"} eq "HASH" or throw_exception("CreateTakesHashRefOfAttributes", "params", \%options, "attribute_class", $class)
MC/DC0%0/3
exists $options{'attributes'} && (ref $options{'attributes'} eq 'HASH' || throw_exception('CreateTakesHashRefOfAttributes', 'params', \%options, 'attribute_class', $class))
exists $options{'attributes'}
ref $options{"attributes"} eq "HASH"
throw_exception("CreateTakesHashRefOfAttributes", "params", \%options, "attribute_class", $class)
Truth table0%0/4
A && B or C
A= exists $options{'attributes'}B= ref $options{"attributes"} eq "HASH"C= throw_exception("CreateTakesHashRefOfAttributes", "params", \%options, "attribute_class", $class)
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | (ref $options{methods} eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||
| 520 | || throw_exception( CreateTakesHashRefOfMethods => params => \%options, | ||||||||||||||||||||||||||||||||||||||||||
| 521 | attribute_class => $class | ||||||||||||||||||||||||||||||||||||||||||
| 522 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 15 | ▶ | if exists $options{methods}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
exists $options{'methods'} && (ref $options{'methods'} eq 'HASH' || throw_exception('CreateTakesHashRefOfMethods', 'params', \%options, 'attribute_class', $class))
ref $options{"methods"} eq "HASH" or throw_exception("CreateTakesHashRefOfMethods", "params", \%options, "attribute_class", $class)
MC/DC0%0/3
exists $options{'methods'} && (ref $options{'methods'} eq 'HASH' || throw_exception('CreateTakesHashRefOfMethods', 'params', \%options, 'attribute_class', $class))
exists $options{'methods'}
ref $options{"methods"} eq "HASH"
throw_exception("CreateTakesHashRefOfMethods", "params", \%options, "attribute_class", $class)
Truth table0%0/4
A && B or C
A= exists $options{'methods'}B= ref $options{"methods"} eq "HASH"C= throw_exception("CreateTakesHashRefOfMethods", "params", \%options, "attribute_class", $class)
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | (ref $options{roles} eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||
| 526 | || throw_exception( CreateTakesArrayRefOfRoles => params => \%options, | ||||||||||||||||||||||||||||||||||||||||||
| 527 | attribute_class => $class | ||||||||||||||||||||||||||||||||||||||||||
| 528 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 14 | ▶ | if exists $options{roles}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
exists $options{'roles'} && (ref $options{'roles'} eq 'ARRAY' || throw_exception('CreateTakesArrayRefOfRoles', 'params', \%options, 'attribute_class', $class))
ref $options{"roles"} eq "ARRAY" or throw_exception("CreateTakesArrayRefOfRoles", "params", \%options, "attribute_class", $class)
MC/DC0%0/3
exists $options{'roles'} && (ref $options{'roles'} eq 'ARRAY' || throw_exception('CreateTakesArrayRefOfRoles', 'params', \%options, 'attribute_class', $class))
exists $options{'roles'}
ref $options{"roles"} eq "ARRAY"
throw_exception("CreateTakesArrayRefOfRoles", "params", \%options, "attribute_class", $class)
Truth table0%0/4
A && B or C
A= exists $options{'roles'}B= ref $options{"roles"} eq "ARRAY"C= throw_exception("CreateTakesArrayRefOfRoles", "params", \%options, "attribute_class", $class)
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 13 | my $package = delete $options{package}; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 13 | my $roles = delete $options{roles}; | |||||||||||||||||||||||||||||||||||||||||
| 533 | 13 | my $attributes = delete $options{attributes}; | |||||||||||||||||||||||||||||||||||||||||
| 534 | 13 | my $methods = delete $options{methods}; | |||||||||||||||||||||||||||||||||||||||||
| 535 | my $meta_name = exists $options{meta_name} | ||||||||||||||||||||||||||||||||||||||||||
| 536 | ? delete $options{meta_name} | ||||||||||||||||||||||||||||||||||||||||||
| 537 | 13 | ▶ | : 'meta'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 13 | my $meta = $class->SUPER::create($package => %options); | |||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | 13 | ▶ | $meta->_add_meta_method($meta_name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | if defined $meta_name; | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | 13 | ▶ | if (defined $attributes) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 2 | foreach my $attribute_name (keys %{$attributes}) { | |||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | my $attr = $attributes->{$attribute_name}; | |||||||||||||||||||||||||||||||||||||||||
| 547 | $meta->add_attribute( | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 2 | ▶ | $attribute_name => blessed $attr ? $attr : %{$attr} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 13 | ▶ | if (defined $methods) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 7 | foreach my $method_name (keys %{$methods}) { | |||||||||||||||||||||||||||||||||||||||||
| 554 | 7 | $meta->add_method($method_name, $methods->{$method_name}); | |||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | 13 | ▶ | if ($roles) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 559 | 1 | Moose::Util::apply_all_roles($meta, @$roles); | |||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | 13 | return $meta; | |||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 3 | ▶ | sub consumers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consumers: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 567 | 3 | my @consumers; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 3 | for my $meta (Class::MOP::get_all_metaclass_instances) { | |||||||||||||||||||||||||||||||||||||||||
| 569 | 225 | ▶ | next if $meta->name eq $self->name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | 222 | ▶ | next unless $meta->isa('Moose::Meta::Class') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$meta->isa("Moose::Meta::Class") or $meta->isa("Moose::Meta::Role")
MC/DC100%2/2
$meta->isa("Moose::Meta::Class") or $meta->isa("Moose::Meta::Role")
$meta->isa("Moose::Meta::Class")
$meta->isa("Moose::Meta::Role")
Truth table100%3/3
A or B
A= $meta->isa("Moose::Meta::Class")B= $meta->isa("Moose::Meta::Role")
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | || $meta->isa('Moose::Meta::Role'); | ||||||||||||||||||||||||||||||||||||||||||
| 572 | 21 | ▶ | push @consumers, $meta->name | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 573 | if $meta->does_role($self->name); | ||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | 3 | return @consumers; | |||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | # XXX: something more intelligent here? | ||||||||||||||||||||||||||||||||||||||||||
| 579 | 38 | ▶ | sub _anon_package_prefix { 'Moose::Meta::Role::__ANON__::SERIAL::' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_anon_package_prefix: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | 11 | ▶ | sub create_anon_role { shift->create_anon(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_anon_role: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | 2 | ▶ | sub is_anon_role { shift->is_anon(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_anon_role: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | sub _anon_cache_key { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_anon_cache_key: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my %options = @_; | |||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | # XXX fix this duplication (see MMC::_anon_cache_key | ||||||||||||||||||||||||||||||||||||||||||
| 589 | my $roles = Data::OptList::mkopt(($options{roles} || []), { | ||||||||||||||||||||||||||||||||||||||||||
| 590 | moniker => 'role', | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | val_test => sub { ref($_[0]) eq 'HASH' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | }); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{'roles'} || []
MC/DC0%0/1
$options{'roles'} || []
$options{'roles'}
Truth table0%0/2
A
A= $options{'roles'}
| |||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my @role_keys; | |||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | for my $role_spec (@$roles) { | |||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my ($role, $params) = @$role_spec; | |||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | $params = { %$params }; | |||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | my $key = blessed($role) ? $role->name : $role; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | if ($params && %$params) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$params and %$params
MC/DC0%0/2
$params and %$params
$params
%$params
Truth table0%0/3
A and B
A= $paramsB= %$params
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | my $alias = delete $params->{'-alias'} | ||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | || delete $params->{'alias'} | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
delete $params->{'-alias'} || delete $params->{'alias'} || {}
delete $params->{"-alias"} or delete $params->{"alias"}
MC/DC0%0/2
delete $params->{'-alias'} || delete $params->{'alias'} || {}
delete $params->{"-alias"}
delete $params->{"alias"}
Truth table0%0/3
A or B
A= delete $params->{"-alias"}B= delete $params->{"alias"}
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | || {}; | ||||||||||||||||||||||||||||||||||||||||||
| 605 | my $excludes = delete $params->{'-excludes'} | ||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | || delete $params->{'excludes'} | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
delete $params->{'-excludes'} || delete $params->{'excludes'} || []
delete $params->{"-excludes"} or delete $params->{"excludes"}
MC/DC0%0/2
delete $params->{'-excludes'} || delete $params->{'excludes'} || []
delete $params->{"-excludes"}
delete $params->{"excludes"}
Truth table0%0/3
A or B
A= delete $params->{"-excludes"}B= delete $params->{"excludes"}
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | || []; | ||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | $excludes = [$excludes] unless ref($excludes) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | if (%$params) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | warn "Roles with parameters cannot be cached. Consider " | |||||||||||||||||||||||||||||||||||||||||
| 612 | . "applying the parameters before calling " | ||||||||||||||||||||||||||||||||||||||||||
| 613 | . "create_anon_class, or using 'weaken => 0' instead"; | ||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | my $alias_key = join('%', | ||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | map { $_ => $alias->{$_} } sort keys %$alias | |||||||||||||||||||||||||||||||||||||||||
| 619 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my $excludes_key = join('%', | |||||||||||||||||||||||||||||||||||||||||
| 621 | sort @$excludes | ||||||||||||||||||||||||||||||||||||||||||
| 622 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>'; | |||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | push @role_keys, $key; | |||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | # Makes something like Role|Role::1 | ||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | return join('|', sort @role_keys); | |||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 634 | ## NOTE: | ||||||||||||||||||||||||||||||||||||||||||
| 635 | ## This is Moose::Meta::Role as defined by Moose (plus the use of | ||||||||||||||||||||||||||||||||||||||||||
| 636 | ## MooseX::AttributeHelpers module). It is here as a reference to | ||||||||||||||||||||||||||||||||||||||||||
| 637 | ## make it easier to see what is happening above with all the meta | ||||||||||||||||||||||||||||||||||||||||||
| 638 | ## programming. - SL | ||||||||||||||||||||||||||||||||||||||||||
| 639 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 640 | # | ||||||||||||||||||||||||||||||||||||||||||
| 641 | # has 'roles' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 642 | # metaclass => 'Array', | ||||||||||||||||||||||||||||||||||||||||||
| 643 | # reader => 'get_roles', | ||||||||||||||||||||||||||||||||||||||||||
| 644 | # isa => 'ArrayRef[Moose::Meta::Role]', | ||||||||||||||||||||||||||||||||||||||||||
| 645 | # default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||||
| 646 | # provides => { | ||||||||||||||||||||||||||||||||||||||||||
| 647 | # 'push' => 'add_role', | ||||||||||||||||||||||||||||||||||||||||||
| 648 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 649 | # ); | ||||||||||||||||||||||||||||||||||||||||||
| 650 | # | ||||||||||||||||||||||||||||||||||||||||||
| 651 | # has 'excluded_roles_map' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 652 | # metaclass => 'Hash', | ||||||||||||||||||||||||||||||||||||||||||
| 653 | # reader => 'get_excluded_roles_map', | ||||||||||||||||||||||||||||||||||||||||||
| 654 | # isa => 'HashRef[Str]', | ||||||||||||||||||||||||||||||||||||||||||
| 655 | # provides => { | ||||||||||||||||||||||||||||||||||||||||||
| 656 | # # Not exactly set, cause it sets multiple | ||||||||||||||||||||||||||||||||||||||||||
| 657 | # 'set' => 'add_excluded_roles', | ||||||||||||||||||||||||||||||||||||||||||
| 658 | # 'keys' => 'get_excluded_roles_list', | ||||||||||||||||||||||||||||||||||||||||||
| 659 | # 'exists' => 'excludes_role', | ||||||||||||||||||||||||||||||||||||||||||
| 660 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 661 | # ); | ||||||||||||||||||||||||||||||||||||||||||
| 662 | # | ||||||||||||||||||||||||||||||||||||||||||
| 663 | # has 'required_methods' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 664 | # metaclass => 'Hash', | ||||||||||||||||||||||||||||||||||||||||||
| 665 | # reader => 'get_required_methods_map', | ||||||||||||||||||||||||||||||||||||||||||
| 666 | # isa => 'HashRef[Moose::Meta::Role::Method::Required]', | ||||||||||||||||||||||||||||||||||||||||||
| 667 | # provides => { | ||||||||||||||||||||||||||||||||||||||||||
| 668 | # # not exactly set, or delete since it works for multiple | ||||||||||||||||||||||||||||||||||||||||||
| 669 | # 'set' => 'add_required_methods', | ||||||||||||||||||||||||||||||||||||||||||
| 670 | # 'delete' => 'remove_required_methods', | ||||||||||||||||||||||||||||||||||||||||||
| 671 | # 'keys' => 'get_required_method_list', | ||||||||||||||||||||||||||||||||||||||||||
| 672 | # 'exists' => 'requires_method', | ||||||||||||||||||||||||||||||||||||||||||
| 673 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 674 | # ); | ||||||||||||||||||||||||||||||||||||||||||
| 675 | # | ||||||||||||||||||||||||||||||||||||||||||
| 676 | # # the before, around and after modifiers are | ||||||||||||||||||||||||||||||||||||||||||
| 677 | # # HASH keyed by method-name, with ARRAY of | ||||||||||||||||||||||||||||||||||||||||||
| 678 | # # CODE refs to apply in that order | ||||||||||||||||||||||||||||||||||||||||||
| 679 | # | ||||||||||||||||||||||||||||||||||||||||||
| 680 | # has 'before_method_modifiers' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 681 | # metaclass => 'Hash', | ||||||||||||||||||||||||||||||||||||||||||
| 682 | # reader => 'get_before_method_modifiers_map', | ||||||||||||||||||||||||||||||||||||||||||
| 683 | # isa => 'HashRef[ArrayRef[CodeRef]]', | ||||||||||||||||||||||||||||||||||||||||||
| 684 | # provides => { | ||||||||||||||||||||||||||||||||||||||||||
| 685 | # 'keys' => 'get_before_method_modifiers', | ||||||||||||||||||||||||||||||||||||||||||
| 686 | # 'exists' => 'has_before_method_modifiers', | ||||||||||||||||||||||||||||||||||||||||||
| 687 | # # This actually makes sure there is an | ||||||||||||||||||||||||||||||||||||||||||
| 688 | # # ARRAY at the given key, and pushed onto | ||||||||||||||||||||||||||||||||||||||||||
| 689 | # # it. It also checks for duplicates as well | ||||||||||||||||||||||||||||||||||||||||||
| 690 | # # 'add' => 'add_before_method_modifier' | ||||||||||||||||||||||||||||||||||||||||||
| 691 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | # ); | ||||||||||||||||||||||||||||||||||||||||||
| 693 | # | ||||||||||||||||||||||||||||||||||||||||||
| 694 | # has 'after_method_modifiers' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 695 | # metaclass => 'Hash', | ||||||||||||||||||||||||||||||||||||||||||
| 696 | # reader =>'get_after_method_modifiers_map', | ||||||||||||||||||||||||||||||||||||||||||
| 697 | # isa => 'HashRef[ArrayRef[CodeRef]]', | ||||||||||||||||||||||||||||||||||||||||||
| 698 | # provides => { | ||||||||||||||||||||||||||||||||||||||||||
| 699 | # 'keys' => 'get_after_method_modifiers', | ||||||||||||||||||||||||||||||||||||||||||
| 700 | # 'exists' => 'has_after_method_modifiers', | ||||||||||||||||||||||||||||||||||||||||||
| 701 | # # This actually makes sure there is an | ||||||||||||||||||||||||||||||||||||||||||
| 702 | # # ARRAY at the given key, and pushed onto | ||||||||||||||||||||||||||||||||||||||||||
| 703 | # # it. It also checks for duplicates as well | ||||||||||||||||||||||||||||||||||||||||||
| 704 | # # 'add' => 'add_after_method_modifier' | ||||||||||||||||||||||||||||||||||||||||||
| 705 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | # ); | ||||||||||||||||||||||||||||||||||||||||||
| 707 | # | ||||||||||||||||||||||||||||||||||||||||||
| 708 | # has 'around_method_modifiers' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 709 | # metaclass => 'Hash', | ||||||||||||||||||||||||||||||||||||||||||
| 710 | # reader =>'get_around_method_modifiers_map', | ||||||||||||||||||||||||||||||||||||||||||
| 711 | # isa => 'HashRef[ArrayRef[CodeRef]]', | ||||||||||||||||||||||||||||||||||||||||||
| 712 | # provides => { | ||||||||||||||||||||||||||||||||||||||||||
| 713 | # 'keys' => 'get_around_method_modifiers', | ||||||||||||||||||||||||||||||||||||||||||
| 714 | # 'exists' => 'has_around_method_modifiers', | ||||||||||||||||||||||||||||||||||||||||||
| 715 | # # This actually makes sure there is an | ||||||||||||||||||||||||||||||||||||||||||
| 716 | # # ARRAY at the given key, and pushed onto | ||||||||||||||||||||||||||||||||||||||||||
| 717 | # # it. It also checks for duplicates as well | ||||||||||||||||||||||||||||||||||||||||||
| 718 | # # 'add' => 'add_around_method_modifier' | ||||||||||||||||||||||||||||||||||||||||||
| 719 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 720 | # ); | ||||||||||||||||||||||||||||||||||||||||||
| 721 | # | ||||||||||||||||||||||||||||||||||||||||||
| 722 | # # override is similar to the other modifiers | ||||||||||||||||||||||||||||||||||||||||||
| 723 | # # except that it is not an ARRAY of code refs | ||||||||||||||||||||||||||||||||||||||||||
| 724 | # # but instead just a single name->code mapping | ||||||||||||||||||||||||||||||||||||||||||
| 725 | # | ||||||||||||||||||||||||||||||||||||||||||
| 726 | # has 'override_method_modifiers' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 727 | # metaclass => 'Hash', | ||||||||||||||||||||||||||||||||||||||||||
| 728 | # reader =>'get_override_method_modifiers_map', | ||||||||||||||||||||||||||||||||||||||||||
| 729 | # isa => 'HashRef[CodeRef]', | ||||||||||||||||||||||||||||||||||||||||||
| 730 | # provides => { | ||||||||||||||||||||||||||||||||||||||||||
| 731 | # 'keys' => 'get_override_method_modifier', | ||||||||||||||||||||||||||||||||||||||||||
| 732 | # 'exists' => 'has_override_method_modifier', | ||||||||||||||||||||||||||||||||||||||||||
| 733 | # 'add' => 'add_override_method_modifier', # checks for local method .. | ||||||||||||||||||||||||||||||||||||||||||
| 734 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 735 | # ); | ||||||||||||||||||||||||||||||||||||||||||
| 736 | # | ||||||||||||||||||||||||||||||||||||||||||
| 737 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | 386 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | # ABSTRACT: The Moose Role metaclass | ||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | __END__ | ||||||||||||||||||||||||||||||||||||||||||