KiokuDB/Thunk.pm

filter: Statementstmt 60.0% 12 / 20 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 1 totaltotal 43.7% 14 / 32 CC 3 SCAR 19.0
CC
3
Cov
48%
vivify
12.0
_build_value
2.0
BEGIN
1.0
CRAP 6.7
« KiokuDB/Test/Fixture/TypeMap/Default.pm ↑ Summary KiokuDB/TypeMap/Entry/Set.pm »
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
BranchTrueFalseTotal
if ref $value and $attr->is_weak_ref 0 0 0
Condition0%0/3
ref $value and $attr->is_weak_ref
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
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  
« KiokuDB/Test/Fixture/TypeMap/Default.pm ↑ Summary KiokuDB/TypeMap/Entry/Set.pm »