| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if(@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $self->{$k} = ref $_[0] eq 'HASH' ? EntityModel::Hash->new($_[0]) : $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | unless($self->{$k}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | return $self->{$k}->get(@_) if @_ == 1 && !ref($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 and not ref $_[0]
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]
| |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | $self->{$k} = ref $_[0] eq 'HASH' ? EntityModel::Hash->new($_[0]) : $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 10 | ▶ | unless($self->{$k}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||