blib/lib/MooX/ObjectBuilder.pm

filter: Statementstmt 97.4% 75 / 77 Branchbran 75.0% 24 / 32 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 17 / 17 Podpod n/a totaltotal 91.1% 124 / 136 CC 27 SCAR 12.1
CC
27
Cov
90%
__ANON__
6.0
__ANON__
4.0
_build_author
4.0
CRAP 3.4
↑ Summary
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
BranchTrueFalseTotal
if ($] < "5.01") 0 9 9
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
BranchTrueFalseTotal
exists &{"${caller}::BUILD";} ? : 0 11 11
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
BranchTrueFalseTotal
exists $params->{$_} ? : 8 0 8
exists $params->{$_} ? : 76 6 82
35 2 ▶ $self->$next(@_) if $next;
Branch: 2 branches
BranchTrueFalseTotal
if $next 0 2 2
if $next 7 19 26
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
BranchTrueFalseTotal
@_ == 1 && ref $_[0] eq 'ARRAY' ? : 2 7 9
Condition66%2/3
@_ == 1 and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
702
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"
ABresult
0X0
100
111
44 20 ▶ @_==1 && ref($_[0]) eq 'ARRAY' ? map(+($_=>$_), @{$_[0]}) :
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 && ref $_[0] eq 'HASH' ? : 11 9 20
Condition100%3/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
7211
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"
ABresult
0X0
100
111
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
BranchTrueFalseTotal
exists $storage->{$_} ? : 27 2 29
exists $storage->{$_} ? : 1 12 13
exists $storage->{$_} ? : 0 2 2
51 13 ▶ my $bless = exists($args{'__CLASS__'}) ? delete($args{'__CLASS__'}) : $klass;
Branch: 2 branches
BranchTrueFalseTotal
exists $args{'__CLASS__'} ? : 7 6 13
exists $args{'__CLASS__'} ? : 4 0 4
52
53 13 ▶ $self->DOES('MooseX::ConstructInstance')
Branch: 2 branches
BranchTrueFalseTotal
$self->DOES('MooseX::ConstructInstance') ? : 0 13 13
$self->DOES('MooseX::ConstructInstance') ? : 0 2 2
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
BranchTrueFalseTotal
wantarray ? : 19 1 20
58 }
59 11 }
60  
61 4 1;
62  
63 __END__
↑ Summary