line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package KiokuDB::Backend::Serialize::JSPON::Converter; |
4
|
6
|
|
|
6
|
|
3423
|
use Moose::Role; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
45
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
24337
|
use namespace::clean -except => 'meta'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
42
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _jspon_fields { |
9
|
38
|
|
|
38
|
|
162
|
return qw( |
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
|
|
|
|
|
|
|
has id_field => ( |
24
|
|
|
|
|
|
|
isa => "Str", |
25
|
|
|
|
|
|
|
is => "ro", |
26
|
|
|
|
|
|
|
default => "id", |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has class_field => ( |
30
|
|
|
|
|
|
|
isa => "Str", |
31
|
|
|
|
|
|
|
is => "ro", |
32
|
|
|
|
|
|
|
default => "__CLASS__", |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has class_meta_field => ( |
36
|
|
|
|
|
|
|
isa => "Str", |
37
|
|
|
|
|
|
|
is => "ro", |
38
|
|
|
|
|
|
|
default => "__META__", |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has class_version_field => ( |
42
|
|
|
|
|
|
|
isa => "Str", |
43
|
|
|
|
|
|
|
is => "ro", |
44
|
|
|
|
|
|
|
default => "__VERSION__", |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has root_field => ( |
48
|
|
|
|
|
|
|
isa => "Str", |
49
|
|
|
|
|
|
|
is => "ro", |
50
|
|
|
|
|
|
|
default => "root", |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has deleted_field => ( |
54
|
|
|
|
|
|
|
isa => "Str", |
55
|
|
|
|
|
|
|
is => "ro", |
56
|
|
|
|
|
|
|
default => "deleted", |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has tied_field => ( |
60
|
|
|
|
|
|
|
isa => "Str", |
61
|
|
|
|
|
|
|
is => "ro", |
62
|
|
|
|
|
|
|
default => "tied", |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has ref_field => ( |
66
|
|
|
|
|
|
|
isa => "Str", |
67
|
|
|
|
|
|
|
is => "ro", |
68
|
|
|
|
|
|
|
default => '$ref', |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has data_field => ( |
72
|
|
|
|
|
|
|
isa => "Str", |
73
|
|
|
|
|
|
|
is => "ro", |
74
|
|
|
|
|
|
|
default => "data", |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
has backend_data_field => ( |
78
|
|
|
|
|
|
|
isa => "Str", |
79
|
|
|
|
|
|
|
is => "ro", |
80
|
|
|
|
|
|
|
default => "backend_data", |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
has _jspon_params => ( |
91
|
|
|
|
|
|
|
isa => "HashRef", |
92
|
|
|
|
|
|
|
is => "ro", |
93
|
|
|
|
|
|
|
lazy_build => 1, |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _build__jspon_params { |
97
|
19
|
|
|
19
|
|
43
|
my $self = shift; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
return { |
100
|
190
|
|
|
|
|
230
|
( map { |
101
|
19
|
100
|
|
|
|
70
|
my $name = "${_}_field"; |
102
|
190
|
|
|
|
|
5645
|
$name => $self->$name |
103
|
|
|
|
|
|
|
} $self->_jspon_fields, |
104
|
|
|
|
|
|
|
), |
105
|
|
|
|
|
|
|
( inline_data => $self->inline_data ? 1 : 0 ), |
106
|
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__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 |