File Coverage

blib/lib/KiokuDB/TypeMap/Entry/Std/Expand.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 32 34 94.1


line stmt bran cond sub pod time code
1             package KiokuDB::TypeMap::Entry::Std::Expand;
2 23     23   12726 use Moose::Role;
  23         39  
  23         171  
3              
4 23     23   97880 no warnings 'recursion';
  23         44  
  23         922  
5              
6 23     23   105 use namespace::clean -except => 'meta';
  23         40  
  23         211  
7              
8             requires qw(
9             compile_create
10             compile_clear
11             compile_expand_data
12             );
13              
14             sub compile_expand {
15 314     314 0 732 my ( $self, $class, @args ) = @_;
16              
17 314         1239 my $create = $self->compile_create($class, @args);
18 314         1248 my $expand_data = $self->compile_expand_data($class, @args);
19              
20             return sub {
21 5234     5234   7883 my ( $linker, $entry, @args ) = @_;
22              
23 5234         14602 my ( $instance, @register_args ) = $linker->$create($entry, @args);
24              
25             # this is registered *before* any other value expansion, to allow circular refs
26 5234         60425 $linker->register_object( $entry => $instance, @register_args );
27              
28 5234         18731 $linker->$expand_data($instance, $entry, @args);
29              
30 5234         16265 return $instance;
31 314         2197 };
32             }
33              
34             sub compile_refresh {
35 314     314 0 830 my ( $self, $class, @args ) = @_;
36              
37 314         1154 my $clear = $self->compile_clear($class, @args);
38 314         859 my $expand_data = $self->compile_expand_data($class, @args);
39              
40             return sub {
41 35     35   76 my ( $linker, $instance, $entry, @args ) = @_;
42              
43 35         165 $linker->$clear($instance, $entry, @args);
44              
45 35         231 $linker->$expand_data($instance, $entry, @args);
46 314         2406 };
47             }
48              
49             __PACKAGE__
50              
51             __END__