| 1 | package Moose::Exception::Role::EitherAttributeOrAttributeName; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 12 | our $VERSION = '2.4001'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use Moose::Util 'throw_exception'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 12 | has 'attribute_name' => ( | |||||||||||||||||||||||||||||||||||||||||
| 8 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 9 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 10 | lazy_build => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 11 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 12 | has 'attribute' => ( | |||||||||||||||||||||||||||||||||||||||||
| 14 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | isa => 'Class::MOP::Attribute', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | predicate => 'has_attribute' | ||||||||||||||||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 12 | has 'params' => ( | |||||||||||||||||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | predicate => 'has_params', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | sub _build_attribute_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_attribute_name: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | ▶ | if( !$self->has_attribute ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | throw_exception("NeitherAttributeNorAttributeNameIsGiven"); | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | return $self->attribute->name; | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 17 | ▶ | after "BUILD" => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 17 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 17 | ▶ | if( $self->has_attribute_name && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->has_attribute_name and $self->has_attribute and $self->attribute->name ne $self->attribute_name
$self->has_attribute_name and $self->has_attribute
MC/DC100%3/3
$self->has_attribute_name and $self->has_attribute and $self->attribute->name ne $self->attribute_name
$self->has_attribute_name
$self->has_attribute
$self->attribute->name ne $self->attribute_name
Truth table100%4/4
A and B and C
A= $self->has_attribute_nameB= $self->has_attributeC= $self->attribute->name ne $self->attribute_name
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | $self->has_attribute && | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ( $self->attribute->name ne $self->attribute_name ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | throw_exception( AttributeNamesDoNotMatch => attribute_name => $self->attribute_name, | |||||||||||||||||||||||||||||||||||||||||
| 44 | attribute => $self->attribute | ||||||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||