KiokuDB/Meta/Instance.pm

filter: Statementstmt 52.9% 9 / 17 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod n/a totaltotal 47.8% 11 / 23 CC 2 SCAR 11.6
CC
2
Cov
47%
__ANON__
6.0
__ANON__
2.0
BEGIN
1.0
CRAP 3.2
« KiokuDB/Serializer.pm ↑ Summary KiokuDB/Backend/Role/TXN.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::Meta::Instance;
4 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 around 'get_slot_value' => sub {
9 0 ▶ my ( $next, $self, $instance, $slot, @args ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
10  
11 0 my $value = $self->$next($instance, $slot, @args);
12  
13 0 ▶ if ( ref($value) eq 'KiokuDB::Thunk' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "KiokuDB::Thunk") 0 0 0
14 0 $value = $value->vivify($instance);
15 }
16  
17 0 return $value;
18 3 };
19  
20 around 'inline_get_slot_value' => sub {
21 0 ▶ my ( $next, $self, $instance_expr, $slot_expr, @args ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
22  
23 0 my $get_expr = $self->$next($instance_expr, $slot_expr, @args);
24  
25 0 return 'do {
26 my $value = ' . $get_expr . ';
27 if ( ref($value) eq "KiokuDB::Thunk" ) {
28 $value = $value->vivify(' . $instance_expr . ');
29 }
30 $value;
31 }'
32 3 };
33  
34 3 __PACKAGE__
35  
36 __END__
37  
38 =pod
39  
40 =head1 NAME
41  
42 KiokuDB::Meta::Instance - L<Moose::Meta::Instnace> level support for lazy loading.
43  
44 =head1 SYNOPSIS
45  
46 # use KiokuDB::Meta::Attribute::Lazy
47  
48 =head1 DESCRIPTION
49  
50 This role is applied to the meta instance class automatically by
51 L<KiokuDB::Class>. When it finds L<KiokuDB::Thunk> objects in the low level
52 attribute storage it will cause them to be loaded.
53  
54 This allows your L<Moose::Meta::Attributes> to remain oblivious to the fact
55 that the value is deferred, making sure that all the type constraints, lazy
56 defaults, and various other L<Moose> features continue to work normally.
57  
« KiokuDB/Serializer.pm ↑ Summary KiokuDB/Backend/Role/TXN.pm »