| 1 | 9 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 0 | ▶ | BEGIN { if ($] < 5.010000) { require UNIVERSAL::DOES } }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | package MooX::ObjectBuilder; | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 4 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||
| 10 | 4 | our $VERSION = '0.002'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use B::Hooks::EndOfScope; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 9 | ▶ | use Exporter::Shiny our(@EXPORT) = qw(make_builder); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 9 | ▶ | use Lexical::Accessor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 9 | ▶ | use MooseX::ConstructInstance -with; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 9 | ▶ | use Sub::Name qw(subname); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | sub _generate_make_builder | ||||||||||||||||||||||||||||
| 19 | 11 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_generate_make_builder: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 11 | my $me = shift; | |||||||||||||||||||||||||||
| 21 | 11 | my ($name, $args, $globals) = @_; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 11 | lexical_has(accessor => \(my $storage)); | |||||||||||||||||||||||||||
| 24 | 11 | my @need_to_store; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 11 | my $caller = $globals->{into}; | |||||||||||||||||||||||||||
| 27 | # around BUILD | ||||||||||||||||||||||||||||
| 28 | 11 | ▶ | on_scope_end { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 29 | 9 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $next = exists(&{"$caller\::BUILD"}) ? \&{"$caller\::BUILD"} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 11 | ▶ | *{"$caller\::BUILD"} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Subroutine
BUILD: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 32 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 33 | 2 | my ($params) = @_; | |||||||||||||||||||||||||||
| 34 | 2 | ▶ | $self->$storage({ map exists($params->{$_})?($_=>$params->{$_}):(), @need_to_store }); | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 35 | 2 | ▶ | $self->$next(@_) if $next; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 36 | 11 | }; | |||||||||||||||||||||||||||
| 37 | 11 | subname("$caller\::BUILD", \&{"$caller\::BUILD"}); | |||||||||||||||||||||||||||
| 38 | 11 | }; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 20 | ▶ | return sub { # make_builder | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||
| 41 | 20 | my $klass = shift; | |||||||||||||||||||||||||||
| 42 | my %attrs = | ||||||||||||||||||||||||||||
| 43 | 11 | ▶ | @_==1 && ref($_[0]) eq 'HASH' ? %{$_[0]} : | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC50%1/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0] eq "ARRAY"
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||
| 44 | 20 | ▶ | @_==1 && ref($_[0]) eq 'ARRAY' ? map(+($_=>$_), @{$_[0]}) : | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC100%2/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 45 | @_; | ||||||||||||||||||||||||||||
| 46 | 20 | push @need_to_store, keys(%attrs); | |||||||||||||||||||||||||||
| 47 | 13 | ▶ | my $code = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
Subroutine
_build_right_eye: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 48 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 49 | 13 | my $storage = $self->$storage; | |||||||||||||||||||||||||||
| 50 | 13 | ▶ | my %args = map exists($storage->{$_})?($attrs{$_}=>$storage->{$_}):(), keys(%attrs); | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 51 | 13 | ▶ | my $bless = exists($args{'__CLASS__'}) ? delete($args{'__CLASS__'}) : $klass; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 13 | ▶ | $self->DOES('MooseX::ConstructInstance') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 54 | ? $self->construct_instance($bless, \%args) | ||||||||||||||||||||||||||||
| 55 | : MooX::ObjectBuilder->construct_instance($bless, \%args); | ||||||||||||||||||||||||||||
| 56 | 20 | }; | |||||||||||||||||||||||||||
| 57 | 20 | ▶ | wantarray ? ('lazy', builder => $code) : $code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 11 | } | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 4 | 1; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||