Property/RW/Lazy.pm

filter: Statementstmt 94.1% 32 / 34 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 86.0% 43 / 50 CC 5 SCAR 8.2
CC
5
Cov
83%
FETCH
4.3
STORE
2.0
BEGIN
1.0
CRAP 2.3
« Property/RW/Lazy/CustomSet.pm ↑ Summary Property/RO/Lazy.pm »
1 package Class::Property::RW::Lazy;
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 parent 'Class::Property::RW';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 sub TIESCALAR
6 3 ▶{
Subroutine TIESCALAR: called CC=1 SCAR=0.0
7 3 my( $class, $field, $init, $flag_ref ) = @_;
8 3 return bless {
9 'field' => $field
10 , 'init' => $init
11 , 'flag_ref' => $flag_ref
12 }, $class;
13 }
14
15 sub STORE
16 2 ▶{
Subroutine STORE: called CC=2 SCAR=7.0
17 2 my( $self, $value ) = @_;
18 2 $self->{'object'}->{$self->{'field'}} = $value;
19 2 ▶ if( not defined $self->{'flag_ref'}->{$self->{'object'}} )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"flag_ref"}{$self->{"object"}}) 2 0 2
20 {
21 2 $self->{'flag_ref'}->{$self->{'object'}} = $self->{'object'};
22 2 Scalar::Util::weaken($self->{'flag_ref'}->{$self->{'object'}});
23 }
24 2 return;
25 }
26
27 sub FETCH
28 4 ▶{
Subroutine FETCH: called CC=4 SCAR=14.6
29 4 my( $self ) = @_;
30
31 4 eval{
32 4 ▶ if( not defined $self->{'flag_ref'}->{$self->{'object'}} )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"flag_ref"}{$self->{"object"}}) 4 0 4
33 {
34 4 $self->{'flag_ref'}->{$self->{'object'}} = $self->{'object'};
35 4 Scalar::Util::weaken($self->{'flag_ref'}->{$self->{'object'}});
36 4 $self->{'object'}->{$self->{'field'}} = $self->{'init'}->($self->{'object'});
37 }
38 };
39 4 ▶if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 4 4
40 {
41 1 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 1 ▶ use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
43 0 print Dumper($self);
44 0 ▶ confess $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
45 }
46
47 4 return $self->{'object'}->{$self->{'field'}};
48 }
49
50 1 1;
« Property/RW/Lazy/CustomSet.pm ↑ Summary Property/RO/Lazy.pm »