line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer2::Session::DBIC::Serializer::JSON; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Dancer2::Session::DBIC::Serializer::JSON |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Use L<JSON::MaybeXS> serialization for session storage. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
35175
|
use JSON::MaybeXS; |
|
2
|
|
|
|
|
4578
|
|
|
2
|
|
|
|
|
96
|
|
14
|
2
|
|
|
2
|
|
413
|
use Moo; |
|
2
|
|
|
|
|
8191
|
|
|
2
|
|
|
|
|
10
|
|
15
|
|
|
|
|
|
|
with 'Dancer2::Session::DBIC::Role::Serializer'; |
16
|
2
|
|
|
2
|
|
1555
|
use namespace::clean; |
|
2
|
|
|
|
|
6228
|
|
|
2
|
|
|
|
|
13
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
See L<Dancer2::Session::DBIC::Role::Serializer> for inherited attributes. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 serialize_options |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Override default with the following options: |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item pretty => 0 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item convert_blessed => 1 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=back |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has '+serialize_options' => ( |
37
|
|
|
|
|
|
|
default => sub { |
38
|
|
|
|
|
|
|
{ pretty => 0, convert_blessed => 1 }; |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 METHODS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 serialize $perl_objects |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Serialize C<$perl_objects> to JSON. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub serialize { |
51
|
22
|
|
|
22
|
1
|
3953
|
shift->serializer->encode(shift); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _build_serializer { |
55
|
6
|
|
|
6
|
|
1047
|
JSON::MaybeXS->new( shift->serialize_options ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 deserialize $json |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Deserialize C<$json> to Perl objects. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub deserialize { |
65
|
41
|
|
|
41
|
1
|
1119
|
shift->deserializer->decode(shift); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _build_deserializer { |
69
|
5
|
|
|
5
|
|
1052
|
JSON::MaybeXS->new( shift->deserialize_options ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |