line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::LazierAttributes; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
8
|
|
594072
|
use strict; |
|
9
|
|
|
|
|
57
|
|
|
9
|
|
|
|
|
214
|
|
4
|
9
|
|
|
8
|
|
1670
|
use warnings; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
164
|
|
5
|
8
|
|
|
8
|
|
1061
|
use Moo; |
|
8
|
|
|
|
|
20707
|
|
|
8
|
|
|
|
|
36
|
|
6
|
8
|
|
|
8
|
|
8246
|
use Clone qw/clone/; |
|
8
|
|
|
|
|
17350
|
|
|
8
|
|
|
|
|
427
|
|
7
|
8
|
|
|
8
|
|
3040
|
use MooX::ReturnModifiers qw/return_has/; |
|
8
|
|
|
|
|
3392
|
|
|
8
|
|
|
|
|
376
|
|
8
|
8
|
|
|
8
|
|
3232
|
use namespace::clean (); |
|
8
|
|
|
|
|
77048
|
|
|
8
|
|
|
|
|
338
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.07008'; |
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
52
|
use constant ro => 'ro'; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
406
|
|
13
|
8
|
|
|
8
|
|
41
|
use constant is_ro => ( is => ro ); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
371
|
|
14
|
8
|
|
|
8
|
|
44
|
use constant rw => 'rw'; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
312
|
|
15
|
8
|
|
|
8
|
|
40
|
use constant is_rw => ( is => rw ); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
299
|
|
16
|
8
|
|
|
8
|
|
37
|
use constant nan => undef; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
318
|
|
17
|
8
|
|
|
8
|
|
52
|
use constant lzy => ( lazy => 1 ); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
303
|
|
18
|
8
|
|
|
8
|
|
33
|
use constant bld => ( builder => 1 ); |
|
8
|
|
|
|
|
31
|
|
|
8
|
|
|
|
|
367
|
|
19
|
8
|
|
|
8
|
|
49
|
use constant lzy_bld => ( lazy_build => 1 ); |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
458
|
|
20
|
8
|
|
|
8
|
|
46
|
use constant trg => ( trigger => 1 ); |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
404
|
|
21
|
8
|
|
|
8
|
|
41
|
use constant clr => ( clearer => 1 ); |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
393
|
|
22
|
8
|
|
|
8
|
|
44
|
use constant req => ( required => 1 ); |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
333
|
|
23
|
8
|
|
|
8
|
|
43
|
use constant coe => ( coerce => 1 ); |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
518
|
|
24
|
8
|
|
|
8
|
|
49
|
use constant lzy_hash => ( lazy => 1, default => sub { {} }); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
554
|
|
|
0
|
|
|
|
|
0
|
|
25
|
8
|
|
|
8
|
|
87
|
use constant lzy_array => ( lazy => 1, default => sub { [] }); |
|
8
|
|
|
|
|
33
|
|
|
8
|
|
|
|
|
530
|
|
|
0
|
|
|
|
|
0
|
|
26
|
8
|
|
|
8
|
|
44
|
use constant lzy_str => (lazy => 1, default => sub { "" }); |
|
8
|
|
|
|
|
79
|
|
|
8
|
|
|
|
|
467
|
|
|
0
|
|
|
|
|
0
|
|
27
|
8
|
|
|
8
|
|
42
|
use constant dhash => (default => sub { {} }); |
|
8
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
525
|
|
|
0
|
|
|
|
|
0
|
|
28
|
8
|
|
|
8
|
|
57
|
use constant darray => (default => sub { [] }); |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
456
|
|
|
0
|
|
|
|
|
0
|
|
29
|
8
|
|
|
8
|
|
40
|
use constant dstr => (default => sub { "" }); |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
2899
|
|
|
0
|
|
|
|
|
0
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub import { |
32
|
11
|
|
|
11
|
|
2951
|
my ($package, @export) = @_; |
33
|
11
|
|
|
|
|
23
|
my $target = caller; |
34
|
11
|
|
|
|
|
33
|
my $has = return_has($target); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $attributes = sub { |
37
|
5
|
|
|
5
|
|
773
|
my @attr = @_; |
38
|
5
|
|
|
|
|
20
|
while (@attr) { |
39
|
31
|
100
|
|
|
|
63184
|
my @names = ref $attr[0] eq 'ARRAY' ? @{ shift @attr } : shift @attr; |
|
3
|
|
|
|
|
8
|
|
40
|
31
|
|
|
|
|
49
|
my @spec = @{ shift(@attr) }; |
|
31
|
|
|
|
|
64
|
|
41
|
|
|
|
|
|
|
|
42
|
31
|
|
|
|
|
45
|
my $eye = 1; |
43
|
|
|
|
|
|
|
splice @spec, $#spec < 1 ? 0 : $eye, 0, delete $spec[-1]->{default} |
44
|
31
|
100
|
100
|
|
|
66
|
if (grep { ref $spec[$_] eq 'Type::Tiny' and $eye = $#spec } (0 .. $#spec) or ref $spec[-1] eq 'HASH' && exists $spec[-1]->{default} ); |
|
56
|
100
|
100
|
|
|
264
|
|
|
|
100
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
31
|
|
|
|
|
61
|
for (@names) { |
47
|
36
|
100
|
100
|
|
|
2366
|
unshift @spec, 'set' if $_ =~ m/^\+/ and ( !$spec[0] || $spec[0] ne 'set' ); |
|
|
|
100
|
|
|
|
|
48
|
36
|
100
|
100
|
|
|
264
|
unshift @spec, ro unless ! ref $spec[0] and $spec[0] =~ m/^(ro|rw|set)$/; |
49
|
36
|
|
|
|
|
79
|
$has->( $_, _construct_attribute(@spec) ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
11
|
|
|
|
|
314
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my @ex = scalar @export |
55
|
11
|
100
|
|
|
|
55
|
? grep { !ref $_ } @export |
|
6
|
|
|
|
|
12
|
|
56
|
|
|
|
|
|
|
: qw/ro is_ro rw is_rw nan lzy bld lzy_bld trg clr req coe lzy_hash lzy_array/; # back compat as import used to accept a {} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
{ |
59
|
8
|
|
|
8
|
|
52
|
no strict 'refs'; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
2429
|
|
|
11
|
|
|
|
|
19
|
|
60
|
132
|
|
|
|
|
250
|
${"${target}::"}{$_} = ${"${package}::"}{$_} |
|
132
|
|
|
|
|
203
|
|
61
|
11
|
|
|
|
|
20
|
foreach @ex; |
62
|
|
|
|
|
|
|
|
63
|
11
|
|
|
|
|
18
|
*{"${target}::attributes"} = $attributes; |
|
11
|
|
|
|
|
43
|
|
64
|
|
|
|
|
|
|
|
65
|
11
|
|
|
|
|
69
|
namespace::clean->import( |
66
|
|
|
|
|
|
|
-cleanee => $target, |
67
|
|
|
|
|
|
|
@ex, 'attributes' |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
11
|
|
|
|
|
1571
|
return 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _construct_attribute { |
75
|
45
|
|
|
45
|
|
4943
|
my @spec = @_; |
76
|
45
|
|
|
|
|
76
|
my %attr = (); |
77
|
45
|
100
|
|
|
|
116
|
$attr{is} = $spec[0] unless $spec[0] eq 'set'; |
78
|
45
|
100
|
|
|
|
99
|
do { $attr{isa} = splice @spec, 1, 1; } if ref $spec[1] eq 'Type::Tiny'; |
|
7
|
|
|
|
|
15
|
|
79
|
26
|
|
|
26
|
|
42847
|
$attr{default} = ref $spec[1] eq 'CODE' ? $spec[1] : sub { clone( $spec[1] ) } |
80
|
45
|
100
|
|
|
|
169
|
if defined $spec[1]; |
|
|
100
|
|
|
|
|
|
81
|
45
|
|
|
|
|
67
|
$attr{$_} = $spec[2]->{$_} foreach keys %{ $spec[2] }; |
|
45
|
|
|
|
|
136
|
|
82
|
45
|
|
|
|
|
197
|
return %attr; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |