KiokuDB/TypeMap/Entry/Naive.pm

filter: Statementstmt 95.8% 23 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 3 totaltotal 86.1% 31 / 36 CC 1 SCAR 0.3
CC
1
Cov
96%
__ANON__
1.1
compile_refresh
1.1
BEGIN
1.0
CRAP 1.0
« KiokuDB/TypeMap/Entry/JSON/Scalar.pm ↑ Summary KiokuDB/Role/UUIDs.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::TypeMap::Entry::Naive;
4 16 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 16 ▶no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 16 with qw(KiokuDB::TypeMap::Entry::Std);
11  
12 sub compile_collapse_body {
13 45 ▶ my ( $self, $class ) = @_;
Subroutine compile_collapse_body: called CC=1 SCAR=0.0
Pod undocumented
14  
15 return sub {
16 44 ▶ my ( $self, %args ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
17  
18 44 my $object = $args{object};
19  
20 44 return $self->make_entry(
21 %args,
22 data => $self->visit_ref_data($object),
23 );
24 45 };
25 }
26  
27 sub compile_expand {
28 45 ▶ my ( $self, $class ) = @_;
Subroutine compile_expand: called CC=1 SCAR=0.0
Pod undocumented
29  
30 return sub {
31 41 ▶ my ( $self, $entry ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
32  
33 41 $self->inflate_data( $entry->data, \( my $obj ), $entry );
34  
35 41 bless $obj, $class;
36 45 };
37 }
38  
39 0 ▶sub compile_refresh { return sub { die "TODO" } }
Subroutine __ANON__: not called CC=1 SCAR=1.2
Subroutine compile_refresh: called CC=1 SCAR=1.2
Pod undocumented
40  
41 16 __PACKAGE__->meta->make_immutable;
42  
43 16 __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
« KiokuDB/TypeMap/Entry/JSON/Scalar.pm ↑ Summary KiokuDB/Role/UUIDs.pm »