line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
483
|
use 5.008; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
140
|
|
2
|
4
|
|
|
4
|
|
17
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
105
|
|
3
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
139
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Role::Commons::Authority; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
16
|
use Carp qw[croak]; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
223
|
|
8
|
4
|
|
|
4
|
|
2048
|
use match::simple qw[match]; |
|
4
|
|
|
|
|
14545
|
|
|
4
|
|
|
|
|
29
|
|
9
|
4
|
|
|
4
|
|
653
|
use Scalar::Util qw[blessed]; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
181
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
12
|
4
|
|
|
4
|
|
16
|
use Moo::Role; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
32
|
|
13
|
4
|
|
|
4
|
|
1207
|
$Role::Commons::Authority::AUTHORITY = 'cpan:TOBYINK'; |
14
|
4
|
|
|
|
|
516
|
$Role::Commons::Authority::VERSION = '0.103'; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our %ENABLE_SHARED; |
18
|
|
|
|
|
|
|
our %SHARED_AUTHORITIES; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $setup_for_class = sub { |
21
|
|
|
|
|
|
|
my ($role, $package, %args) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
if ( exists $args{-authorities} ) |
24
|
|
|
|
|
|
|
{ |
25
|
|
|
|
|
|
|
$ENABLE_SHARED{ $package } = 1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
ref($args{-authorities}) eq 'ARRAY' and |
28
|
|
|
|
|
|
|
$SHARED_AUTHORITIES{ $package } = $args{-authorities}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub AUTHORITY |
33
|
|
|
|
|
|
|
{ |
34
|
4
|
|
|
4
|
1
|
1530
|
my ($invocant, $test) = @_; |
35
|
4
|
50
|
|
|
|
16
|
$invocant = ref $invocant if blessed($invocant); |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
4
|
my @authorities = do { |
38
|
4
|
|
|
4
|
|
20
|
no strict 'refs'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
720
|
|
39
|
4
|
|
|
|
|
6
|
my @a = ${"$invocant\::AUTHORITY"}; |
|
4
|
|
|
|
|
15
|
|
40
|
4
|
50
|
|
|
|
12
|
if (exists $ENABLE_SHARED{ $invocant }) |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
0
|
|
|
|
0
|
push @a, @{$SHARED_AUTHORITIES{$invocant} || []}; |
|
0
|
|
|
|
|
0
|
|
43
|
0
|
|
|
|
|
0
|
push @a, @{"$invocant\::AUTHORITIES"}; |
|
0
|
|
|
|
|
0
|
|
44
|
|
|
|
|
|
|
} |
45
|
4
|
|
|
|
|
8
|
@a; |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
4
|
100
|
|
|
|
12
|
if (scalar @_ > 1) |
49
|
|
|
|
|
|
|
{ |
50
|
2
|
|
|
|
|
2
|
my $ok = undef; |
51
|
2
|
|
|
|
|
4
|
AUTH: for my $A (@authorities) |
52
|
|
|
|
|
|
|
{ |
53
|
2
|
100
|
|
|
|
9
|
if (match($A, $test)) |
54
|
|
|
|
|
|
|
{ |
55
|
1
|
|
|
|
|
2
|
$ok = $A; |
56
|
1
|
|
|
|
|
3
|
last AUTH; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
2
|
100
|
|
|
|
10
|
return $ok if defined $ok; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
@authorities |
62
|
1
|
50
|
|
|
|
173
|
? croak("Invocant ($invocant) has authority '$authorities[0]'") |
63
|
|
|
|
|
|
|
: croak("Invocant ($invocant) has no authority defined"); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
2
|
50
|
|
|
|
15
|
wantarray ? @authorities : $authorities[0]; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |