blib/lib/Clustericious/Client/Object.pm

filter: Statementstmt 100% 50 / 50 Branchbran 86.3% 19 / 22 Conditioncond 66.6% 8 / 12 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 88.2% 90 / 102 CC 17 SCAR 19.0
CC
17
Cov
92%
__ANON__
10.9
new
7.0
_client
2.0
CRAP 6.7
« blib/lib/Clustericious/Config.pm ↑ Summary blib/lib/Clustericious/Command/morbo.pm »
1 package Clustericious::Client::Object;
2  
3 44 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 44 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: default object returned from client methods
7 44 our $VERSION = '1.29'; # VERSION
8  
9  
10 sub new
11 19 ▶{
Subroutine new: called CC=7 SCAR=19.5
Pod documented
12 19 my $class = shift;
13 19 my ($self, $client) = @_;
14  
15 19 ▶ return $self unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 2 17 19
16  
17 17 ▶ if (ref $self eq 'ARRAY')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self eq "ARRAY") 5 12 17
18 {
19 5 foreach (@$self)
20 {
21 11 ▶ $_ = $class->new($_, $client) if ref eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "HASH" 3 8 11
22 }
23 5 return $self;
24 }
25  
26 44 ▶ while (my ($attr, $type) = do { no strict 'refs'; each %{"${class}::classes"} })
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if (() = do { no strict 'refs'; each %{"${class}::classes";} }) 2 12 14
27 {
28 2 eval "require $type";
29  
30 2 ▶ if (exists $self->{$attr})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{$attr}) 2 0 2
31 {
32 2 $self->{$attr} = $type->new($self->{$attr}, $client)
33 }
34 }
35  
36 12 bless $self, $class;
37  
38 12 $self->_client($client);
39  
40 12 return $self;
41 }
42  
43 {
44 44 my %clientcache;
45  
46  
47 sub _client
48 13 ▶ {
Subroutine _client: called CC=2 SCAR=6.9
49 13 my $self = shift;
50 13 my ($client) = @_;
51
52 13 ▶ $client ? ($clientcache{$self} = $client) : $clientcache{$self};
Branch: 1 branch
BranchTrueFalseTotal
$client ? : 1 12 13
53 }
54  
55 sub DESTROY
56 12 ▶ {
Subroutine DESTROY: called CC=1 SCAR=0.0
57 12 delete $clientcache{shift};
58 }
59 }
60  
61 sub AUTOLOAD
62 44 ▶{
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
63 8 my $self = shift;
64  
65 8 my ($class, $called) = our $AUTOLOAD =~ /^(.+)::([^:]+)$/;
66  
67 my $sub = sub
68 14 ▶ {
Subroutine __ANON__: called CC=10 SCAR=23.9
69 14 my $self = shift;
70 14 my ($value) = @_;
71  
72 14 ▶ $self->{$called} = $value if defined $value; # Can't set undef
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 1 13 14
73
74 14 $value = $self->{$called};
75  
76 14 ▶ if (ref $value eq 'HASH' or ref $value eq 'ARRAY')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "HASH" or ref $value eq "ARRAY") 4 10 14
Condition100%3/3
ref $value eq "HASH" or ref $value eq "ARRAY"
l!l&&r!l&&!r
1310
MC/DC100%2/2
ref $value eq "HASH" or ref $value eq "ARRAY"
ref $value eq "HASH" ref $value eq "ARRAY"
Truth table100%3/3
A or B
A= ref $value eq "HASH"B= ref $value eq "ARRAY"
ABresult
1X1
011
000
77 {
78 4 $value = __PACKAGE__->new($value);
79 }
80  
81 14 ▶ return wantarray && !defined($value) ? ()
Branch: 3 branches
BranchTrueFalseTotal
wantarray && !defined($value) ? : 0 14 14
wantarray && ref $value eq 'ARRAY' ? : 1 13 14
wantarray && ref $value ? : 0 13 13
Condition55%5/9
wantarray and not defined $value
!ll&&!rl&&r
1310
wantarray and ref $value eq "ARRAY"
!ll&&!rl&&r
1301
wantarray and ref $value
!ll&&!rl&&r
1300
MC/DC0%0/2
wantarray and not defined $value
wantarray not defined $value
MC/DC50%1/2
wantarray and ref $value eq "ARRAY"
wantarray ref $value eq "ARRAY"
MC/DC0%0/2
wantarray and ref $value
wantarray ref $value
Truth table66%2/3
A and not(B)
A= wantarrayB= not defined $value
ABresult
0X0
100
111
Truth table66%2/3
A and B
A= wantarrayB= ref $value eq "ARRAY"
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= wantarrayB= ref $value
ABresult
0X0
100
111
82 : wantarray && (ref $value eq 'ARRAY') ? @$value
83 : wantarray && (ref $value) ? %$value
84 : $value;
85 8 };
86  
87 44 ▶ do { no strict 'refs'; *{ "${class}::$called" } = $sub };
Subroutine BEGIN: called CC=1 SCAR=0.0
88  
89 8 $self->$called(@_);
90 }
91  
92 44 1;
93  
94 __END__
« blib/lib/Clustericious/Config.pm ↑ Summary blib/lib/Clustericious/Command/morbo.pm »