File Coverage

blib/lib/KiokuDB/TypeMap/Entry/Naive.pm
Criterion Covered Total %
statement 2 4 50.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 4 6 66.6


line stmt bran cond sub pod time code
1             package KiokuDB::TypeMap::Entry::Naive;
2             BEGIN {
3 1     1   24997 $KiokuDB::TypeMap::Entry::Naive::AUTHORITY = 'cpan:NUFFIN';
4             }
5             $KiokuDB::TypeMap::Entry::Naive::VERSION = '0.57';
6 1     1   1733 use Moose;
  0            
  0            
7             # ABSTRACT: A typemap entry for "simple" objects
8              
9             no warnings 'recursion';
10              
11             use namespace::clean -except => 'meta';
12              
13             with qw(KiokuDB::TypeMap::Entry::Std);
14              
15             sub compile_collapse_body {
16             my ( $self, $class ) = @_;
17              
18             return sub {
19             my ( $self, %args ) = @_;
20              
21             my $object = $args{object};
22              
23             return $self->make_entry(
24             %args,
25             data => $self->visit_ref_data($object),
26             );
27             };
28             }
29              
30             sub compile_expand {
31             my ( $self, $class ) = @_;
32              
33             return sub {
34             my ( $self, $entry ) = @_;
35              
36             $self->inflate_data( $entry->data, \( my $obj ), $entry );
37              
38             bless $obj, $class;
39             };
40             }
41              
42             sub compile_refresh { return sub { die "TODO" } }
43              
44             __PACKAGE__->meta->make_immutable;
45              
46             __PACKAGE__
47              
48             __END__
49              
50             =pod
51              
52             =encoding UTF-8
53              
54             =head1 NAME
55              
56             KiokuDB::TypeMap::Entry::Naive - A typemap entry for "simple" objects
57              
58             =head1 VERSION
59              
60             version 0.57
61              
62             =head1 SYNOPSIS
63              
64             KiokuDB::TypeMap->new(
65             entires => {
66             'My::Class' => KiokuDB::TypeMap::Entry::Naive->new,
67             },
68             );
69              
70             =head1 DESCRIPTION
71              
72             This typemap entry is suitable for plain objects that can be stored by simply
73             walking them recursively.
74              
75             Most objects fall into this category, but there are notable exceptions:
76              
77             =over 4
78              
79             =item XS based objects, using a pointer as a number
80              
81             When being deserialized the pointer value will no longer be valid, causing
82             segfaults.
83              
84             =item Inside out objects
85              
86             Since the referent is really a flyweight object with no data, the object will
87             be missing its attributes and a suitable typemap entry is required instead.
88              
89             This applies to any object interacting with a global state of some sort.
90              
91             =item Objects with magic
92              
93             Perl SV level magic is not retained, apart from tied values.
94              
95             =back
96              
97             =head1 ATTRIBUTES
98              
99             =over 4
100              
101             =item intrinsic
102              
103             If true the object will be collapsed without an ID as part of its parent.
104              
105             =back
106              
107             =head1 AUTHOR
108              
109             Yuval Kogman <nothingmuch@woobling.org>
110              
111             =head1 COPYRIGHT AND LICENSE
112              
113             This software is copyright (c) 2014 by Yuval Kogman, Infinity Interactive.
114              
115             This is free software; you can redistribute it and/or modify it under
116             the same terms as the Perl 5 programming language system itself.
117              
118             =cut