KiokuDB/Backend/Serialize/JSPON/Converter.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 30 / 30 CC 2 SCAR 3.4
CC
2
Cov
100%
_build__jspon_params
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« KiokuDB/Reference.pm ↑ Summary KiokuDB/Serializer/JSON.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::Backend::Serialize::JSPON::Converter;
4 6 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub _jspon_fields {
9 38 ▶ return qw(
Subroutine _jspon_fields: called CC=1 SCAR=0.0
10 id
11 class
12 class_meta
13 class_version
14 root
15 deleted
16 tied
17 ref
18 data
19 backend_data
20 );
21 }
22  
23 6 has id_field => (
24 isa => "Str",
25 is => "ro",
26 default => "id",
27 );
28  
29 6 has class_field => (
30 isa => "Str",
31 is => "ro",
32 default => "__CLASS__",
33 );
34  
35 6 has class_meta_field => (
36 isa => "Str",
37 is => "ro",
38 default => "__META__",
39 );
40  
41 6 has class_version_field => (
42 isa => "Str",
43 is => "ro",
44 default => "__VERSION__",
45 );
46  
47 6 has root_field => (
48 isa => "Str",
49 is => "ro",
50 default => "root",
51 );
52  
53 6 has deleted_field => (
54 isa => "Str",
55 is => "ro",
56 default => "deleted",
57 );
58  
59 6 has tied_field => (
60 isa => "Str",
61 is => "ro",
62 default => "tied",
63 );
64  
65 6 has ref_field => (
66 isa => "Str",
67 is => "ro",
68 default => '$ref',
69 );
70  
71 6 has data_field => (
72 isa => "Str",
73 is => "ro",
74 default => "data",
75 );
76  
77 6 has backend_data_field => (
78 isa => "Str",
79 is => "ro",
80 default => "backend_data",
81 );
82  
83 6 has inline_data => (
84 isa => "Bool",
85 is => "ro",
86 default => 0,
87 );
88  
89 # kinda ugly, used to pass options down to expander/collapser from backend
90 6 has _jspon_params => (
91 isa => "HashRef",
92 is => "ro",
93 lazy_build => 1,
94 );
95  
96 sub _build__jspon_params {
97 19 ▶ my $self = shift;
Subroutine _build__jspon_params: called CC=2 SCAR=6.9
98  
99 return {
100 ( map {
101 19 my $name = "${_}_field";
102 190 ▶ $name => $self->$name
Branch: 1 branch
BranchTrueFalseTotal
$self->inline_data ? : 1 18 19
103 } $self->_jspon_fields,
104 ),
105 ( inline_data => $self->inline_data ? 1 : 0 ),
106 };
107 }
108  
109 6 __PACKAGE__
110  
111 __END__
112  
113 =pod
114  
115 =head1 NAME
116  
117 KiokuDB::Backend::Serialize::JSPON::Converter - Common functionality for JSPON
118 expansion/collapsing
119  
120 =head1 SYNOPSIS
121  
122 # internal
123  
124 =head1 DESCRIPTION
125  
126 These attributes are shared by both
127 L<KiokuDB::Backend::Serialize::JSPON::Converter> and
128 L<KiokuDB::Backend::Serialize::JSPON::Expander>.
129  
130 These attributes are also available in L<KiokuDB::Backend::Serialize::JSPON>
131 and passed to the constructors of the expander and the collapser.
132  
133 =head1 ATTRIBUTES
134  
135 =over 4
136  
137 =item id_field
138  
139 =item class_field
140  
141 =item class_meta_field
142  
143 =item root_field
144  
145 =item deleted_field
146  
147 =item tied_field
148  
149 =item data_field
150  
151 =item ref_field
152  
153 The various field name mappings for the L<KiokuDB::Entry> attributes.
154  
155 Everything defaults to the attribute name, except C<class> and C<class_meta>
156 which default to C<__CLASS__> and C<__META__> for compatibility with
157 L<MooseX::Storage> when C<inline_data> is set, and C<ref_field> which is set to
158 C<$ref> according to the JSPON spec.
159  
160 =item inline_data
161  
162 Determines whether or not the entry data keys are escaped and the data is
163 stored in the same top level mapping, or inside a the C<data_field> key.
164  
165 =back
166  
167 =cut
« KiokuDB/Reference.pm ↑ Summary KiokuDB/Serializer/JSON.pm »