| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 17 | ▶ | if (ref $self eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | foreach (@$self) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 11 | ▶ | $_ = $class->new($_, $client) if ref eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | eval "require $type"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | if (exists $self->{$attr}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 14 | $value = $self->{$called}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 14 | ▶ | if (ref $value eq 'HASH' or ref $value eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $value eq "HASH" or ref $value eq "ARRAY"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | $value = __PACKAGE__->new($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 14 | ▶ | return wantarray && !defined($value) ? () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition55%5/9
wantarray and not defined $value
wantarray and ref $value eq "ARRAY"
wantarray and ref $value
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
Truth table66%2/3
A and B
A= wantarrayB= ref $value eq "ARRAY"
Truth table33%1/3
A and B
A= wantarrayB= ref $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||