File Coverage

blib/lib/KiokuDB/TypeMap/Entry/Naive.pm
Criterion Covered Total %
statement 20 21 95.2
branch n/a
condition n/a
subroutine 8 9 88.8
pod 0 3 0.0
total 28 33 84.8


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             package KiokuDB::TypeMap::Entry::Naive;
4 16     16   36352 use Moose;
  16         346009  
  16         122  
5              
6 16     16   84309 no warnings 'recursion';
  16         33  
  16         688  
7              
8 16     16   75 use namespace::clean -except => 'meta';
  16         25  
  16         150  
9              
10             with qw(KiokuDB::TypeMap::Entry::Std);
11              
12             sub compile_collapse_body {
13 57     57 0 153 my ( $self, $class ) = @_;
14              
15             return sub {
16 56     56   193 my ( $self, %args ) = @_;
17              
18 56         108 my $object = $args{object};
19              
20 56         333 return $self->make_entry(
21             %args,
22             data => $self->visit_ref_data($object),
23             );
24 57         387 };
25             }
26              
27             sub compile_expand {
28 57     57 0 95 my ( $self, $class ) = @_;
29              
30             return sub {
31 56     56   84 my ( $self, $entry ) = @_;
32              
33 56         1302 $self->inflate_data( $entry->data, \( my $obj ), $entry );
34              
35 56         224 bless $obj, $class;
36 57         385 };
37             }
38              
39 0     0 0 0 sub compile_refresh { return sub { die "TODO" } }
  57     57   313  
40              
41             __PACKAGE__->meta->make_immutable;
42              
43             __PACKAGE__
44              
45             __END__
46              
47             =pod
48              
49             =head1 NAME
50              
51             KiokuDB::TypeMap::Entry::Naive - A typemap entry for "simple" objects
52              
53             =head1 SYNOPSIS
54              
55             KiokuDB::TypeMap->new(
56             entires => {
57             'My::Class' => KiokuDB::TypeMap::Entry::Naive->new,
58             },
59             );
60              
61             =head1 DESCRIPTION
62              
63             This typemap entry is suitable for plain objects that can be stored by simply
64             walking them recursively.
65              
66             Most objects fall into this category, but there are notable exceptions:
67              
68             =over 4
69              
70             =item XS based objects, using a pointer as a number
71              
72             When being deserialized the pointer value will no longer be valid, causing
73             segfaults.
74              
75             =item Inside out objects
76              
77             Since the referant is really a flyweight object with no data, the object will
78             be missing its attributes and a suitable typemap entry is required instead.
79              
80             This applies to any object interacting with a global state of some sort.
81              
82             =item Objects with magic
83              
84             Perl SV level magic is not retained, apart from tied values.
85              
86             =back
87              
88             =head1 ATTRIBUTES
89              
90             =over 4
91              
92             =item intrinsic
93              
94             If true the object will be collapsed without an ID as part of its parent.
95              
96             =back