Property/RO/Lazy.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 25 / 25 CC 2 SCAR 2.9
CC
2
Cov
100%
FETCH
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Property/RW/Lazy.pm ↑ Summary Property/RW/CustomSet.pm »
1 package Class::Property::RO::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::RO';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 sub TIESCALAR
6 1 ▶{
Subroutine TIESCALAR: called CC=1 SCAR=0.0
7 1 my( $class, $field, $init, $flag_ref ) = @_;
8 1 return bless {
9 'field' => $field
10 , 'init' => $init
11 , 'flag_ref' => $flag_ref
12 }, $class;
13 }
14
15 sub FETCH
16 4 ▶{
Subroutine FETCH: called CC=2 SCAR=6.9
17 4 my( $self ) = @_;
18
19 4 ▶ if( not defined $self->{'flag_ref'}->{$self->{'object'}} )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"flag_ref"}{$self->{"object"}}) 2 2 4
20 {
21 2 $self->{'flag_ref'}->{$self->{'object'}} = $self->{'object'};
22 2 Scalar::Util::weaken($self->{'flag_ref'}->{$self->{'object'}});
23 2 $self->{'object'}->{$self->{'field'}} = $self->{'init'}->($self->{'object'});
24 }
25
26 4 return $self->{'object'}->{$self->{'field'}};
27 }
28
29 1 1;
« Property/RW/Lazy.pm ↑ Summary Property/RW/CustomSet.pm »