line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# --8<--8<--8<--8<-- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (C) 2012 Smithsonian Astrophysical Observatory |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This file is part of MooX-Attributes-Shadow |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# MooX-Attributes-Shadow is free software: you can redistribute it and/or modify |
8
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
9
|
|
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or (at |
10
|
|
|
|
|
|
|
# your option) any later version. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
13
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
|
|
|
|
# GNU General Public License for more details. |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
18
|
|
|
|
|
|
|
# along with this program. If not, see . |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# -->8-->8-->8-->8-- |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package MooX::Attributes::Shadow::Role; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
4
|
|
195753
|
use strict; |
|
4
|
|
|
|
|
33
|
|
|
4
|
|
|
|
|
260
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
4
|
|
25
|
use Moo::Role; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
31
|
|
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
4
|
|
2541
|
use MooX::Attributes::Shadow ':all'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
836
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
## no critic (ProhibitSubroutinePrototypes) |
33
|
|
|
|
|
|
|
sub shadowable_attrs (@) { |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
4
|
1
|
1385948
|
my $attrs = [@_]; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
## no critic (ProhibitNoStrict) |
38
|
4
|
|
|
4
|
|
30
|
no strict 'refs'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
232
|
|
39
|
4
|
|
|
4
|
|
24
|
no warnings 'redefine'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1455
|
|
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
9
|
|
26
|
*{ caller() . '::shadowable_attrs' } = sub (@) { @{$attrs} }; |
|
4
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
2752
|
|
|
9
|
|
|
|
|
60
|
|
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
|
|
51
|
return; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new_from_attrs (@) { |
47
|
|
|
|
|
|
|
|
48
|
5
|
|
|
5
|
1
|
1204
|
my $contained = shift; |
49
|
|
|
|
|
|
|
|
50
|
5
|
|
|
|
|
7
|
my $container = shift; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# handle the following cases: |
53
|
|
|
|
|
|
|
# @args = ( \%options ); |
54
|
|
|
|
|
|
|
# @args = ( \%options, %attr ); |
55
|
|
|
|
|
|
|
# @args = ( \%options, \%attrs ); |
56
|
|
|
|
|
|
|
# @args = ( %attr ); |
57
|
|
|
|
|
|
|
|
58
|
5
|
|
|
|
|
6
|
my $options = {}; |
59
|
5
|
|
|
|
|
6
|
my %attrs; |
60
|
|
|
|
|
|
|
|
61
|
5
|
100
|
100
|
|
|
33
|
if ( @_ == 1 ) { |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
2
|
$options = shift; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
elsif ( @_ == 2 && 'HASH' eq ref $_[0] && 'HASH' eq ref $_[1] ) { |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
2
|
$options = shift; |
70
|
1
|
|
|
|
|
3
|
%attrs = %{ shift() }; |
|
1
|
|
|
|
|
3
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
elsif ( @_ % 2 ) { |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
1
|
$options = shift; |
77
|
1
|
|
|
|
|
2
|
%attrs = @_; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
else { |
82
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
5
|
%attrs = @_; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
5
|
|
|
|
|
18
|
return $contained->new( $contained->xtract_attrs( $container, $options ), %attrs ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |