| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package KiokuDB::Thunk; | ||||||||||||||||||||||||||||
| 4 | 22 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 22 | ▶ | use namespace::clean -except => 'meta'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 22 | has collapsed => ( | |||||||||||||||||||||||||||
| 9 | isa => "Ref", | ||||||||||||||||||||||||||||
| 10 | is => "ro", | ||||||||||||||||||||||||||||
| 11 | required => 1, | ||||||||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 22 | has linker => ( | |||||||||||||||||||||||||||
| 15 | isa => "KiokuDB::Linker", | ||||||||||||||||||||||||||||
| 16 | is => "ro", | ||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 22 | has attr => ( | |||||||||||||||||||||||||||
| 20 | isa => "Class::MOP::Attribute", | ||||||||||||||||||||||||||||
| 21 | is => "ro", | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 22 | has value => ( | |||||||||||||||||||||||||||
| 25 | isa => "Ref", | ||||||||||||||||||||||||||||
| 26 | is => "ro", | ||||||||||||||||||||||||||||
| 27 | lazy_build => 1, | ||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | sub _build_value { | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_value: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | return $self->linker->expand_object($self->collapsed); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub vivify { | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my ( $self, $instance ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
vivify: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my $value = $self->value; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | my $attr = $self->attr; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | $attr->set_raw_value($instance, $value); | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $attr->_weaken_value($instance) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $value and $attr->is_weak_ref
MC/DC0%0/2
ref $value and $attr->is_weak_ref
ref $value
$attr->is_weak_ref
Truth table0%0/3
A and B
A= ref $valueB= $attr->is_weak_ref
| |||||||||||||||||||||||||||||
| 46 | if ref $value and $attr->is_weak_ref; | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | return $value; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 22 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 22 | __PACKAGE__ | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =pod | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head1 NAME | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | KiokuDB::Thunk - Internal only placeholder for deferred objects | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # do not use directly, | ||||||||||||||||||||||||||||
| 66 | # KiokuDB::Meta::Attribute::Lazy, KiokuDB::Meta::Instance and | ||||||||||||||||||||||||||||
| 67 | # KiokuDB::TypeMap::Entry::MOP will do the actual thunking of data so that | ||||||||||||||||||||||||||||
| 68 | # the thunk will never be visible unless you break encapsulation. | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | This is an internal placeholder object. It will be used on attributes that you | ||||||||||||||||||||||||||||
| 73 | mark with L<KiokuDB::Meta::Attribute::Lazy> automatically, and should never be | ||||||||||||||||||||||||||||
| 74 | visible to the user because L<KiokuDB::Meta::Instance> will automatically | ||||||||||||||||||||||||||||
| 75 | inflate it before it's even seen by the accessor's code. | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||