| 1 | package Class::Accessor::Lazy::Original; | ||||||||||||||||||||
| 2 | 1 | ▶ | use strict; use warnings FATAL => 'all'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use Exporter 'import'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | our $VERSION = '1.000'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | our @EXPORT; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 1 | push @EXPORT, 'original_accessors'; | |||||||||||||||||||
| 10 | 1 | ▶ | sub original_accessors{ | ||||||||||||||||||
|
Subroutine
original_accessors: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 11 | 1 | my $self = shift; | |||||||||||||||||||
| 12 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | *{"${class}::make_accessor"} = \&Class::Accessor::make_accessor; | |||||||||||||||||||
| 17 | 1 | *{"${class}::make_ro_accessor"} = \&Class::Accessor::make_ro_accessor; | |||||||||||||||||||
| 18 | 1 | *{"${class}::make_wo_accessor"} = \&Class::Accessor::make_wo_accessor; | |||||||||||||||||||
| 19 | 1 | *{"${class}::make_lazy_accessor"} = \&Class::Accessor::Lazy::Original::make_accessor; | |||||||||||||||||||
| 20 | 1 | *{"${class}::make_lazy_ro_accessor"} = \&Class::Accessor::Lazy::Original::make_ro_accessor; | |||||||||||||||||||
| 21 | 1 | *{"${class}::make_lazy_wo_accessor"} = \&Class::Accessor::Lazy::Original::make_wo_accessor; | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 1 | return $self; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub make_accessor { | ||||||||||||||||||
|
Subroutine
make_accessor: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 27 | 0 | my ($class, $field) = @_; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 0 | ▶ | return sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 30 | 0 | my $self = shift; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | ▶ | if(@_) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | { | ||||||||||||||||||||
| 34 | 0 | ▶ | $self->{'__lazy_inits'}->{$field} = 1 unless exists $self->{'__lazy_inits'}->{$field}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | 0 | return $self->set($field, @_); | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | else | ||||||||||||||||||||
| 38 | { | ||||||||||||||||||||
| 39 | 0 | ▶ | unless (exists $self->{'__lazy_inits'}->{$field}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | { | ||||||||||||||||||||
| 41 | 0 | my $init_method = "_lazy_init_$field"; | |||||||||||||||||||
| 42 | 0 | $self->$init_method(); | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | $self->{'__lazy_inits'}->{$field} = 1; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | return $self->get($field); | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | 0 | }; | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 2 | ▶ | sub make_ro_accessor { | ||||||||||||||||||
|
Subroutine
make_ro_accessor: called CC=1 SCAR=0.1
Pod
undocumented
| |||||||||||||||||||||
| 53 | 2 | my($class, $field) = @_; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 8 | ▶ | return sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
| |||||||||||||||||||||
| 56 | 8 | my $self = shift; | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 8 | ▶ | if (@_) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 59 | { | ||||||||||||||||||||
| 60 | 0 | my $caller = caller; | |||||||||||||||||||
| 61 | 0 | $self->_croak("'$caller' cannot alter the value of '$field' on objects of class '$class'"); | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | else | ||||||||||||||||||||
| 64 | { | ||||||||||||||||||||
| 65 | 8 | ▶ | if (not exists $self->{'__lazy_inits'}->{$field}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | { | ||||||||||||||||||||
| 67 | 4 | my $init_method = "_lazy_init_$field"; | |||||||||||||||||||
| 68 | 4 | $self->$init_method(); | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 4 | $self->{'__lazy_inits'}->{$field} = 1; | |||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | 8 | return $self->get($field); | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | 2 | }; | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | # requires only for best_practice rw acessors | ||||||||||||||||||||
| 78 | 1 | ▶ | sub make_wo_accessor { | ||||||||||||||||||
|
Subroutine
make_wo_accessor: called CC=1 SCAR=0.4
Pod
undocumented
| |||||||||||||||||||||
| 79 | 1 | my($class, $field) = @_; | |||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 2 | ▶ | return sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.7
| |||||||||||||||||||||
| 82 | 2 | my $self = shift; | |||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 2 | ▶ | unless (@_) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | { | ||||||||||||||||||||
| 86 | 0 | my $caller = caller; | |||||||||||||||||||
| 87 | 0 | $self->_croak("'$caller' cannot access the value of '$field' on objects of class '$class'"); | |||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | else | ||||||||||||||||||||
| 90 | { | ||||||||||||||||||||
| 91 | 2 | ▶ | $self->{'__lazy_inits'}->{$field} = 1 unless exists $self->{'__lazy_inits'}->{$field}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 92 | 2 | return $self->set($field, @_); | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | 1 | }; | |||||||||||||||||||
| 95 | } | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | 1 | 1; | |||||||||||||||||||