| 1 | package HashDataRole::Spec::Basic; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||
| 4 | 3 | our $DATE = '2021-06-01'; # DATE | |||||||||
| 5 | 3 | our $DIST = 'HashData'; # DIST | |||||||||
| 6 | 3 | our $VERSION = '0.1.1'; # VERSION | |||||||||
| 7 | |||||||||||
| 8 | 3 | ▶ | use Role::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 3 | ▶ | use Role::Tiny::With; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | # constructor | ||||||||||
| 12 | 3 | requires 'new'; | |||||||||
| 13 | |||||||||||
| 14 | # mixin | ||||||||||
| 15 | 3 | with 'Role::TinyCommons::Iterator::Resettable'; | |||||||||
| 16 | 3 | with 'Role::TinyCommons::Collection::GetItemByKey'; | |||||||||
| 17 | |||||||||||
| 18 | # provides | ||||||||||
| 19 | |||||||||||
| 20 | 3 | my @role_prefixes = qw(HashDataRole Role::TinyCommons::Collection); | |||||||||
| 21 | sub apply_roles { | ||||||||||
| 22 | 0 | ▶ | my ($obj, @unqualified_roles) = @_; | ||||||||
|
Subroutine
apply_roles: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 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 }; | |||||||||
| 33 | 0 | ▶ | unless ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 3 | 1; | |||||||||
| 52 | # ABSTRACT: Required methods for all HashData::* classes | ||||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||