blib/lib/Moose/Exception/Role/EitherAttributeOrAttributeName.pm

filter: Statementstmt 100% 19 / 19 Branchbran 100% 4 / 4 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 3 / 3 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 36 / 36 CC 5 SCAR 10.1
CC
5
Cov
100%
__ANON__
4.0
_build_attribute_name
2.0
BEGIN
1.0
CRAP 2.8
« blib/lib/Moose/Meta/TypeConstraint/Union.pm ↑ Summary blib/lib/Class/MOP/Mixin/HasOverloads.pm »
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
BranchTrueFalseTotal
unless ($self->has_attribute) 1 2 3
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
BranchTrueFalseTotal
if ($self->has_attribute_name and $self->has_attribute and $self->attribute->name ne $self->attribute_name) 1 16 17
Condition100%6/6
$self->has_attribute_name and $self->has_attribute and $self->attribute->name ne $self->attribute_name
!ll&&!rl&&r
1511
$self->has_attribute_name and $self->has_attribute
!ll&&!rl&&r
3122
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
ABCresult
0XX0
10X0
1100
1111
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;
« blib/lib/Moose/Meta/TypeConstraint/Union.pm ↑ Summary blib/lib/Class/MOP/Mixin/HasOverloads.pm »