Class/Accessor/Hash.pm

filter: Statementstmt 69.7% 23 / 33 Branchbran 22.2% 4 / 18 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 53.1% 34 / 64 CC 11 SCAR 26.2
CC
11
Cov
50%
__ANON__
30.0
__ANON__
12.2
method_list
3.2
CRAP 13.7
« BaseClass.pm ↑ Summary Class/Accessor/Array.pm »
1 package EntityModel::Class::Accessor::Hash;
2 3 $EntityModel::Class::Accessor::Hash::VERSION = '0.016';
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use parent qw{EntityModel::Class::Accessor};
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use EntityModel::Hash;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 EntityModel::Class::Accessor::Array - generic class accessor for arrays
13  
14 =head1 VERSION
15  
16 Version 0.016
17  
18 =head1 DESCRIPTION
19  
20 See L<EntityModel::Class>.
21  
22 =head1 METHODS
23  
24 =cut
25  
26 =head2 method_list
27  
28 Returns a hash of method definitions.
29  
30 =cut
31  
32 2 ▶sub method_list {
Subroutine method_list: called CC=2 SCAR=11.7
Pod documented
33 2 my ($class, %opt) = @_;
34 2 my $k = $opt{k};
35 2 ▶ if(my $pre = $opt{pre}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pre = $opt{'pre'}) { } 0 2 2
36 0 ▶ return sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
37 0 my $self = shift;
38  
39 0 ▶ $pre->($self, @_) or return;
Branch: 1 branch
BranchTrueFalseTotal
&$pre($self, @_) or return 0 0 0
40  
41 0 ▶ if(@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
42 0 ▶ $self->{$k} = ref $_[0] eq 'HASH' ? EntityModel::Hash->new($_[0]) : $_[0];
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
43 }
44 0 ▶ unless($self->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{$k}) 0 0 0
45 0 $self->{$k} = EntityModel::Hash->new($self->{$k});
46 }
47 0 return $self->{$k};
48 0 };
49 } else {
50 10 ▶ return sub {
Subroutine __ANON__: called CC=6 SCAR=25.0
51 10 my $self = shift;
52  
53 10 ▶ if(@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 10 10
54 0 ▶ return $self->{$k}->get(@_) if @_ == 1 && !ref($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 and not ref $_[0] 0 0 0
Condition0%0/3
@_ == 1 and not ref $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and not ref $_[0]
@_ == 1 not ref $_[0]
Truth table0%0/3
A and not(B)
A= @_ == 1B= not ref $_[0]
ABresult
0X0
100
111
55 0 ▶ $self->{$k} = ref $_[0] eq 'HASH' ? EntityModel::Hash->new($_[0]) : $_[0];
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
56 }
57 10 ▶ unless($self->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{$k}) 2 8 10
58 2 $self->{$k} = EntityModel::Hash->new($self->{$k});
59 }
60 10 return $self->{$k};
61 2 };
62 }
63 }
64  
65 3 1;
66  
67 __END__
« BaseClass.pm ↑ Summary Class/Accessor/Array.pm »