| 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
| |||||||||||
| 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; | |||||||||