line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HashDataRole::Spec::Basic; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2021-06-01'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'HashData'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.1.1'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
718
|
use Role::Tiny; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
195
|
use Role::Tiny::With; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
285
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# constructor |
12
|
|
|
|
|
|
|
requires 'new'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# mixin |
15
|
|
|
|
|
|
|
with 'Role::TinyCommons::Iterator::Resettable'; |
16
|
|
|
|
|
|
|
with 'Role::TinyCommons::Collection::GetItemByKey'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# provides |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @role_prefixes = qw(HashDataRole Role::TinyCommons::Collection); |
21
|
|
|
|
|
|
|
sub apply_roles { |
22
|
0
|
|
|
0
|
1
|
|
my ($obj, @unqualified_roles) = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my @roles_to_apply; |
25
|
|
|
|
|
|
|
ROLE: |
26
|
0
|
|
|
|
|
|
for my $ur (@unqualified_roles) { |
27
|
|
|
|
|
|
|
PREFIX: |
28
|
0
|
|
|
|
|
|
for my $prefix (@role_prefixes) { |
29
|
0
|
|
|
|
|
|
my ($mod, $modpm); |
30
|
0
|
|
|
|
|
|
$mod = "$prefix\::$ur"; |
31
|
0
|
|
|
|
|
|
($modpm = "$mod.pm") =~ s!::!/!g; |
32
|
0
|
|
|
|
|
|
eval { require $modpm; 1 }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
unless ($@) { |
34
|
|
|
|
|
|
|
#print "D:$mod\n"; |
35
|
0
|
|
|
|
|
|
push @roles_to_apply, $mod; |
36
|
0
|
|
|
|
|
|
next ROLE; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
|
die "Can't find role '$ur' to apply (searched these prefixes: ". |
40
|
|
|
|
|
|
|
join(", ", @role_prefixes); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
Role::Tiny->apply_roles_to_object($obj, @roles_to_apply); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# return something useful |
46
|
0
|
|
|
|
|
|
$obj; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
### |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
# ABSTRACT: Required methods for all HashData::* classes |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |