line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer2::Session::DBIC::Serializer::YAML; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Dancer2::Session::DBIC::Serializer::YAML |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Use YAML serialization for session storage. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
B<NOTE:> you must install L<YAML> version >= 1.15 to use this serializer. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
40848
|
use YAML 1.15 (); |
|
2
|
|
|
|
|
37
|
|
|
2
|
|
|
|
|
44
|
|
16
|
2
|
|
|
2
|
|
842
|
use YAML::Dumper; |
|
2
|
|
|
|
|
15366
|
|
|
2
|
|
|
|
|
55
|
|
17
|
2
|
|
|
2
|
|
1020
|
use YAML::Loader; |
|
2
|
|
|
|
|
11933
|
|
|
2
|
|
|
|
|
46
|
|
18
|
2
|
|
|
2
|
|
429
|
use Moo; |
|
2
|
|
|
|
|
8328
|
|
|
2
|
|
|
|
|
14
|
|
19
|
|
|
|
|
|
|
with 'Dancer2::Session::DBIC::Role::Serializer'; |
20
|
2
|
|
|
2
|
|
1672
|
use namespace::clean; |
|
2
|
|
|
|
|
6330
|
|
|
2
|
|
|
|
|
24
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
See L<Dancer2::Session::DBIC::Role::Serializer> for inherited attributes. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 serialize_options |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Override default with the following options: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=over |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item indent_width => 1 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=back |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has '+serialize_options' => ( |
39
|
|
|
|
|
|
|
default => sub { |
40
|
|
|
|
|
|
|
{ indent_width => 1 }; |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 serialize $perl_objects |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Serialize C<$perl_objects> to YAML using L<YAML::Dumper>. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub serialize { |
53
|
7
|
|
|
7
|
1
|
2973
|
shift->serializer->dump(shift); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _build_serializer { |
57
|
3
|
|
|
3
|
|
437
|
YAML::Dumper->new( %{ shift->serialize_options } ); |
|
3
|
|
|
|
|
45
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 deserialize $yaml |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Deserialize C<$yaml> to Perl objects using L<YAML::Loader>. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub deserialize { |
67
|
11
|
|
|
11
|
1
|
1512
|
shift->deserializer->load(shift); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _build_deserializer { |
71
|
2
|
|
|
2
|
|
422
|
YAML::Loader->new( %{ shift->deserialize_options } ); |
|
2
|
|
|
|
|
37
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |