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
|
|
296749
|
use strict; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
176
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.04'; # TRIAL |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
24
|
use Moo::Role; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
25
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
3283
|
use namespace::clean; |
|
4
|
|
|
|
|
44449
|
|
|
4
|
|
|
|
|
27
|
|
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
1731
|
use MooX::Attributes::Shadow; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
500
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# make sure we have symbols in this package, so namespace clean test passes. |
16
|
8
|
|
|
8
|
1
|
506
|
sub shadow_attrs { goto \&MooX::Attributes::Shadow::shadow_attrs }; |
17
|
2
|
|
|
2
|
1
|
2386
|
sub shadowed_attrs { goto \&MooX::Attributes::Shadow::shadowed_attrs }; |
18
|
9
|
|
|
9
|
1
|
11265
|
sub xtract_attrs { goto \&MooX::Attributes::Shadow::xtract_attrs }; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
## no critic (ProhibitSubroutinePrototypes) |
21
|
|
|
|
|
|
|
sub shadowable_attrs (@) { |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
4
|
1
|
86665
|
my $attrs = [@_]; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
## no critic (ProhibitNoStrict) |
26
|
4
|
|
|
4
|
|
29
|
no strict 'refs'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
123
|
|
27
|
4
|
|
|
4
|
|
23
|
no warnings 'redefine'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1421
|
|
28
|
|
|
|
|
|
|
|
29
|
4
|
|
|
9
|
|
20
|
*{ caller() . '::shadowable_attrs' } = sub (@) { @{$attrs} }; |
|
4
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
2178
|
|
|
9
|
|
|
|
|
46
|
|
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
23
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new_from_attrs (@) { |
35
|
|
|
|
|
|
|
|
36
|
5
|
|
|
5
|
1
|
1384
|
my $contained = shift; |
37
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
8
|
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
|
|
|
|
|
11
|
my $options = {}; |
47
|
5
|
|
|
|
|
6
|
my %attrs; |
48
|
|
|
|
|
|
|
|
49
|
5
|
100
|
100
|
|
|
30
|
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
|
|
|
|
|
3
|
$options = shift; |
65
|
1
|
|
|
|
|
3
|
%attrs = @_; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
else { |
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
6
|
%attrs = @_; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
5
|
|
|
|
|
12
|
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__ |