| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Business::NAB::Role::AttributeContainer; |
|
2
|
|
|
|
|
|
|
$Business::NAB::Role::AttributeContainer::VERSION = '0.03'; |
|
3
|
|
|
|
|
|
|
# undocument role |
|
4
|
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
8517
|
use strict; |
|
|
8
|
|
|
|
|
25
|
|
|
|
8
|
|
|
|
|
424
|
|
|
6
|
8
|
|
|
8
|
|
90
|
use warnings; |
|
|
8
|
|
|
|
|
31
|
|
|
|
8
|
|
|
|
|
718
|
|
|
7
|
8
|
|
|
8
|
|
82
|
use feature qw/ signatures /; |
|
|
8
|
|
|
|
|
57
|
|
|
|
8
|
|
|
|
|
1365
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
5026
|
use Moose::Role; |
|
|
8
|
|
|
|
|
54646
|
|
|
|
8
|
|
|
|
|
79
|
|
|
10
|
8
|
|
|
8
|
|
64725
|
use Moose::Util::TypeConstraints; |
|
|
8
|
|
|
|
|
35
|
|
|
|
8
|
|
|
|
|
116
|
|
|
11
|
8
|
|
|
8
|
|
24370
|
no warnings qw/ experimental::signatures /; |
|
|
8
|
|
|
|
|
24
|
|
|
|
8
|
|
|
|
|
537
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
8
|
|
|
8
|
|
6982
|
use Module::Load; |
|
|
8
|
|
|
|
|
16823
|
|
|
|
8
|
|
|
|
|
69
|
|
|
14
|
8
|
|
|
8
|
|
4334
|
use Business::NAB::Types qw/ decamelize /; |
|
|
8
|
|
|
|
|
42
|
|
|
|
8
|
|
|
|
|
5082
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub load_attributes ( |
|
17
|
11
|
|
|
|
|
35
|
$self, |
|
18
|
11
|
|
|
|
|
53
|
$parent, |
|
19
|
11
|
|
|
|
|
39
|
@subclasses, |
|
20
|
11
|
|
|
11
|
0
|
37
|
) { |
|
|
11
|
|
|
|
|
26
|
|
|
21
|
11
|
|
|
|
|
42
|
foreach my $record_type ( @subclasses ) { |
|
22
|
|
|
|
|
|
|
|
|
23
|
35
|
|
|
|
|
1793328
|
load( $parent . "::$record_type" ); |
|
24
|
|
|
|
|
|
|
|
|
25
|
35
|
|
|
|
|
147347
|
my $attr = decamelize( $record_type ); |
|
26
|
35
|
|
|
|
|
179
|
my $class = "${parent}::$record_type"; |
|
27
|
|
|
|
|
|
|
|
|
28
|
35
|
|
|
|
|
330
|
subtype $record_type |
|
29
|
|
|
|
|
|
|
=> as "ArrayRef[$class]"; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
coerce $record_type |
|
32
|
|
|
|
|
|
|
=> from "ArrayRef[HashRef|$class]" |
|
33
|
|
|
|
|
|
|
=> via { |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# when a new thing is pushed onto the array we need to coerce |
|
36
|
|
|
|
|
|
|
# it from a HashRef to the instance of the class, but if it's |
|
37
|
|
|
|
|
|
|
# already an instance of the class then pass it straight through |
|
38
|
|
|
|
|
|
|
my @objects = map { |
|
39
|
163
|
100
|
|
|
|
3569
|
ref $_ eq $class |
|
40
|
|
|
|
|
|
|
? $_ |
|
41
|
|
|
|
|
|
|
: $class->new( $_ ) |
|
42
|
46
|
|
|
46
|
|
19221
|
} @{ $_ }; |
|
|
46
|
|
|
|
|
123
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
46
|
|
|
|
|
453
|
[ @objects ]; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
=> from "ArrayRef[Any]" |
|
47
|
|
|
|
|
|
|
=> via { |
|
48
|
1
|
|
|
1
|
|
3824
|
[ $class->new( $_->@* ) ] |
|
49
|
|
|
|
|
|
|
} |
|
50
|
35
|
|
|
|
|
342579
|
; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$parent->meta->add_attribute( |
|
53
|
|
|
|
|
|
|
$attr, |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
|
|
|
|
|
|
traits => [ 'Array' ], |
|
56
|
|
|
|
|
|
|
is => 'rw', |
|
57
|
|
|
|
|
|
|
isa => $record_type, |
|
58
|
|
|
|
|
|
|
coerce => 1, |
|
59
|
47
|
|
|
47
|
|
2329
|
default => sub { [] }, |
|
60
|
35
|
|
|
|
|
342440
|
handles => { |
|
61
|
|
|
|
|
|
|
"add_${attr}" => 'push', |
|
62
|
|
|
|
|
|
|
}, |
|
63
|
|
|
|
|
|
|
}, |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |