| 1 | package MooX::Role::Reconstruct; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 11 | our $VERSION = 'v0.1.2'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 11 | ▶ | use Sub::Quote; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 11 | ▶ | use Sub::Defer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 11 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 10 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 15 | 10 | my $target = shift; | |||||||||||||||||||||||||||
| 16 | 10 | ▶ | my %args = @_ ? (@_) : ( method => 'reconstruct' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 10 | my $method = delete( $args{method} ); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | die 'MooX::Role::Reconstruct can only be used on Moo classes.' | ||||||||||||||||||||||||||||
| 21 | 10 | ▶ | unless $Moo::MAKERS{$target} && $Moo::MAKERS{$target}{is_class}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Moo::MAKERS{$target} and $Moo::MAKERS{$target}{"is_class"}
MC/DC0%0/2
$Moo::MAKERS{$target} and $Moo::MAKERS{$target}{"is_class"}
$Moo::MAKERS{$target}
$Moo::MAKERS{$target}{"is_class"}
Truth table33%1/3
A and B
A= $Moo::MAKERS{$target}B= $Moo::MAKERS{$target}{"is_class"}
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 10 | my $con = Moo->_constructor_maker_for($target); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | defer_sub( | ||||||||||||||||||||||||||||
| 26 | 10 | ▶ | "${target}::${method}" => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # don't alter the original specs if called before new | ||||||||||||||||||||||||||||
| 29 | 10 | my %spec; | |||||||||||||||||||||||||||
| 30 | 10 | for ( keys( %{ $con->{attribute_specs} } ) ) { | |||||||||||||||||||||||||||
| 31 | 22 | $spec{$_} = { %{ $con->{attribute_specs}{$_} } }; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 10 | for ( grep exists( $spec{$_}{init_arg} ), keys(%spec) ) | |||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||
| 35 | 19 | ▶ | delete($spec{$_}{init_arg}) unless $spec{$_}{keep_init}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 10 | unquote_sub $con->generate_method( | |||||||||||||||||||||||||||
| 38 | $target, $method, \%spec, { no_install => 1 } | ||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 10 | ); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 10 | return; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 11 | 1; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||||||||||