line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Exception::Role::EitherAttributeOrAttributeName; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2206'; |
3
|
|
|
|
|
|
|
|
4
|
12
|
|
|
12
|
|
7432
|
use Moose::Util 'throw_exception'; |
|
12
|
|
|
|
|
35
|
|
|
12
|
|
|
|
|
108
|
|
5
|
12
|
|
|
12
|
|
4405
|
use Moose::Role; |
|
12
|
|
|
|
|
35
|
|
|
12
|
|
|
|
|
84
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'attribute_name' => ( |
8
|
|
|
|
|
|
|
is => 'ro', |
9
|
|
|
|
|
|
|
isa => 'Str', |
10
|
|
|
|
|
|
|
lazy_build => 1 |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'attribute' => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
isa => 'Class::MOP::Attribute', |
16
|
|
|
|
|
|
|
predicate => 'has_attribute' |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'params' => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => 'HashRef', |
22
|
|
|
|
|
|
|
predicate => 'has_params', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _build_attribute_name { |
26
|
3
|
|
|
3
|
|
10
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
3
|
100
|
|
|
|
116
|
if( !$self->has_attribute ) |
29
|
|
|
|
|
|
|
{ |
30
|
1
|
|
|
|
|
4
|
throw_exception("NeitherAttributeNorAttributeNameIsGiven"); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
105
|
return $self->attribute->name; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
after "BUILD" => sub { |
37
|
|
|
|
|
|
|
my $self = $_[0]; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
if( $self->has_attribute_name && |
40
|
|
|
|
|
|
|
$self->has_attribute && |
41
|
|
|
|
|
|
|
( $self->attribute->name ne $self->attribute_name ) ) |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
throw_exception( AttributeNamesDoNotMatch => attribute_name => $self->attribute_name, |
44
|
|
|
|
|
|
|
attribute => $self->attribute |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |