line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Role::Reconstruct; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
116880
|
use strict; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
431
|
|
4
|
11
|
|
|
11
|
|
43
|
use warnings FATAL => 'all'; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
358
|
|
5
|
|
|
|
|
|
|
|
6
|
11
|
|
|
11
|
|
246
|
use 5.006; |
|
11
|
|
|
|
|
27
|
|
|
11
|
|
|
|
|
495
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 'v0.1.1'; |
9
|
|
|
|
|
|
|
|
10
|
11
|
|
|
11
|
|
11346
|
use Sub::Quote; |
|
11
|
|
|
|
|
27249
|
|
|
11
|
|
|
|
|
637
|
|
11
|
11
|
|
|
11
|
|
54
|
use Sub::Defer; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
439
|
|
12
|
11
|
|
|
11
|
|
42
|
use Role::Tiny; |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
73
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
15
|
10
|
|
|
10
|
|
112333
|
my $target = shift; |
16
|
10
|
50
|
|
|
|
60
|
my %args = @_ ? (@_) : ( method => 'reconstruct' ); |
17
|
|
|
|
|
|
|
|
18
|
10
|
|
|
|
|
28
|
my $method = delete( $args{method} ); |
19
|
|
|
|
|
|
|
|
20
|
10
|
50
|
33
|
|
|
99
|
die 'MooX::Role::Reconstruct can only be used on Moo classes.' |
21
|
|
|
|
|
|
|
unless $Moo::MAKERS{$target} && $Moo::MAKERS{$target}{is_class}; |
22
|
|
|
|
|
|
|
|
23
|
10
|
|
|
|
|
37
|
my $con = Moo->_constructor_maker_for($target); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
defer_sub( |
26
|
|
|
|
|
|
|
"${target}::${method}" => sub { |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# don't alter the original specs if called before new |
29
|
10
|
|
|
10
|
|
19211
|
my %spec; |
30
|
10
|
|
|
|
|
22
|
for ( keys( %{ $con->{attribute_specs} } ) ) { |
|
10
|
|
|
|
|
73
|
|
31
|
22
|
|
|
|
|
26
|
$spec{$_} = { %{ $con->{attribute_specs}{$_} } }; |
|
22
|
|
|
|
|
100
|
|
32
|
|
|
|
|
|
|
} |
33
|
10
|
|
|
|
|
58
|
for ( grep exists( $spec{$_}{init_arg} ), keys(%spec) ) |
34
|
|
|
|
|
|
|
{ |
35
|
19
|
100
|
|
|
|
79
|
delete($spec{$_}{init_arg}) unless $spec{$_}{keep_init}; |
36
|
|
|
|
|
|
|
} |
37
|
10
|
|
|
|
|
65
|
unquote_sub $con->generate_method( |
38
|
|
|
|
|
|
|
$target, $method, \%spec, { no_install => 1 } |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
10
|
|
|
|
|
122
|
); |
42
|
|
|
|
|
|
|
|
43
|
10
|
|
|
|
|
339
|
return; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |