| 1 | package Class::MOP::Mixin::AttributeCore; | ||||||||||||||||||||||||||||||||||
| 2 | 459 | our $VERSION = '2.4001'; | |||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||
| 4 | 459 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 459 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 459 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | 459 | ▶ | use parent 'Class::MOP::Mixin'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | 87966 | ▶ | sub has_accessor { defined $_[0]->{'accessor'} } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_accessor: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 88032 | ▶ | sub has_reader { defined $_[0]->{'reader'} } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_reader: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | 87925 | ▶ | sub has_writer { defined $_[0]->{'writer'} } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_writer: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | 87923 | ▶ | sub has_predicate { defined $_[0]->{'predicate'} } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_predicate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 87921 | ▶ | sub has_clearer { defined $_[0]->{'clearer'} } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_clearer: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | 76437 | ▶ | sub has_builder { defined $_[0]->{'builder'} } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_builder: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | 347 | ▶ | sub has_init_arg { defined $_[0]->{'init_arg'} } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_init_arg: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | 121929 | ▶ | sub has_default { exists $_[0]->{'default'} } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 19 | 288639 | ▶ | sub has_initializer { defined $_[0]->{'initializer'} } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_initializer: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub has_insertion_order { defined $_[0]->{'insertion_order'} } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_insertion_order: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | 58607 | ▶ | sub _set_insertion_order { $_[0]->{'insertion_order'} = $_[1] } | ||||||||||||||||||||||||||||||||
|
Subroutine
_set_insertion_order: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | 100 | ▶ | sub has_read_method { $_[0]->has_reader || $_[0]->has_accessor } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_read_method: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub has_write_method { $_[0]->has_writer || $_[0]->has_accessor } | ||||||||||||||||||||||||||||||||
|
Subroutine
has_write_method: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | 92363 | ▶ | sub is_default_a_coderef { | ||||||||||||||||||||||||||||||||
|
Subroutine
is_default_a_coderef: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 28 | # Uber hack because it is called from CMOP::Attribute constructor as | ||||||||||||||||||||||||||||||||||
| 29 | # $class->is_default_a_coderef(\%options) | ||||||||||||||||||||||||||||||||||
| 30 | 92363 | ▶ | my ($value) = ref $_[0] ? $_[0]->{'default'} : $_[1]->{'default'}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 92363 | ▶ | return unless ref($value); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | 67492 | ▶ | return ref($value) eq 'CODE' | ||||||||||||||||||||||||||||||||
|
Condition100%6/6
ref $value eq 'CODE' || builtin::blessed($value) && $value->isa('Class::MOP::Method')
builtin::blessed($value) and $value->isa("Class::MOP::Method")
MC/DC100%3/3
ref $value eq 'CODE' || builtin::blessed($value) && $value->isa('Class::MOP::Method')
ref $value eq 'CODE'
builtin::blessed($value)
$value->isa("Class::MOP::Method")
Truth table100%4/4
A || B and C
A= ref $value eq 'CODE'B= builtin::blessed($value)C= $value->isa("Class::MOP::Method")
| |||||||||||||||||||||||||||||||||||
| 35 | || ( blessed($value) && $value->isa('Class::MOP::Method') ); | ||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||
| 38 | 178520 | ▶ | sub default { | ||||||||||||||||||||||||||||||||
|
Subroutine
default: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 39 | 178520 | my ( $self, $instance ) = @_; | |||||||||||||||||||||||||||||||||
| 40 | 178520 | ▶ | if ( defined $instance && $self->is_default_a_coderef ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $instance and $self->is_default_a_coderef
MC/DC100%2/2
defined $instance and $self->is_default_a_coderef
defined $instance
$self->is_default_a_coderef
Truth table100%3/3
A and B
A= defined $instanceB= $self->is_default_a_coderef
| |||||||||||||||||||||||||||||||||||
| 41 | # if the default is a CODE ref, then we pass in the instance and | ||||||||||||||||||||||||||||||||||
| 42 | # default can return a value based on that instance. Somewhat crude, | ||||||||||||||||||||||||||||||||||
| 43 | # but works. | ||||||||||||||||||||||||||||||||||
| 44 | 28087 | return $self->{'default'}->($instance); | |||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||
| 46 | 150433 | $self->{'default'}; | |||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | 459 | 1; | |||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | # ABSTRACT: Core attributes shared by attribute metaclasses | ||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||||||||