File Coverage

blib/lib/ArrayDataRole/Spec/Basic.pm
Criterion Covered Total %
statement 12 28 42.8
branch 0 2 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 36 47.2


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