line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Attributes::Shadow::Role; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: enumerate shadowable attributes in a contained class |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
292146
|
use strict; |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
177
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
25
|
use Moo::Role; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
23
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
3280
|
use namespace::clean; |
|
4
|
|
|
|
|
44157
|
|
|
4
|
|
|
|
|
26
|
|
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
1680
|
use MooX::Attributes::Shadow; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
531
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# make sure we have symbols in this package, so namespace clean test passes. |
16
|
8
|
|
|
8
|
1
|
490
|
sub shadow_attrs { goto \&MooX::Attributes::Shadow::shadow_attrs }; |
17
|
2
|
|
|
2
|
1
|
2363
|
sub shadowed_attrs { goto \&MooX::Attributes::Shadow::shadowed_attrs }; |
18
|
9
|
|
|
9
|
1
|
11106
|
sub xtract_attrs { goto \&MooX::Attributes::Shadow::xtract_attrs }; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
## no critic (ProhibitSubroutinePrototypes) |
21
|
|
|
|
|
|
|
sub shadowable_attrs (@) { |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
4
|
1
|
85485
|
my $attrs = [@_]; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
## no critic (ProhibitNoStrict) |
26
|
4
|
|
|
4
|
|
34
|
no strict 'refs'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
134
|
|
27
|
4
|
|
|
4
|
|
25
|
no warnings 'redefine'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1034
|
|
28
|
|
|
|
|
|
|
|
29
|
4
|
|
|
9
|
|
21
|
*{ caller() . '::shadowable_attrs' } = sub (@) { @{$attrs} }; |
|
4
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
2162
|
|
|
9
|
|
|
|
|
56
|
|
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
13
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new_from_attrs (@) { |
35
|
|
|
|
|
|
|
|
36
|
5
|
|
|
5
|
1
|
1344
|
my $contained = shift; |
37
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
10
|
my $container = shift; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# handle the following cases: |
41
|
|
|
|
|
|
|
# @args = ( \%options ); |
42
|
|
|
|
|
|
|
# @args = ( \%options, %attr ); |
43
|
|
|
|
|
|
|
# @args = ( \%options, \%attrs ); |
44
|
|
|
|
|
|
|
# @args = ( %attr ); |
45
|
|
|
|
|
|
|
|
46
|
5
|
|
|
|
|
8
|
my $options = {}; |
47
|
5
|
|
|
|
|
8
|
my %attrs; |
48
|
|
|
|
|
|
|
|
49
|
5
|
100
|
100
|
|
|
33
|
if ( @_ == 1 ) { |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
3
|
$options = shift; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
elsif ( @_ == 2 && 'HASH' eq ref $_[0] && 'HASH' eq ref $_[1] ) { |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
3
|
$options = shift; |
58
|
1
|
|
|
|
|
2
|
%attrs = %{ shift() }; |
|
1
|
|
|
|
|
4
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
elsif ( @_ % 2 ) { |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
2
|
$options = shift; |
65
|
1
|
|
|
|
|
4
|
%attrs = @_; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
else { |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
6
|
%attrs = @_; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
5
|
|
|
|
|
14
|
return $contained->new( $contained->xtract_attrs( $container, $options ), %attrs ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# |
81
|
|
|
|
|
|
|
# This file is part of MooX-Attributes-Shadow |
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
# This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory. |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# This is free software, licensed under: |
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
88
|
|
|
|
|
|
|
# |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |