DBIC/Serializer/JSON.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 27 / 27 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« DBIC/Role/Serializer.pm ↑ Summary DBIC/Serializer/Sereal.pm »
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 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 with 'Dancer2::Session::DBIC::Role::Serializer';
16 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 1 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
38 1 { pretty => 0, convert_blessed => 1 };
39 },
40 2 );
41  
42 =head1 METHODS
43  
44 =head2 serialize $perl_objects
45  
46 Serialize C<$perl_objects> to JSON.
47  
48 =cut
49  
50 22 ▶sub serialize {
Subroutine serialize: called CC=1 SCAR=0.0
Pod documented
51 22 shift->serializer->encode(shift);
52 }
53  
54 6 ▶sub _build_serializer {
Subroutine _build_serializer: called CC=1 SCAR=0.0
55 6 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 45 ▶sub deserialize {
Subroutine deserialize: called CC=1 SCAR=0.0
Pod documented
65 45 shift->deserializer->decode(shift);
66 }
67  
68 5 ▶sub _build_deserializer {
Subroutine _build_deserializer: called CC=1 SCAR=0.0
69 5 JSON::MaybeXS->new( shift->deserialize_options );
70 }
71  
72 2 1;
« DBIC/Role/Serializer.pm ↑ Summary DBIC/Serializer/Sereal.pm »