| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package KiokuDB::Serializer; |
|
4
|
22
|
|
|
22
|
|
127637
|
use Moose::Role; |
|
|
22
|
|
|
|
|
231542
|
|
|
|
22
|
|
|
|
|
180
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
22
|
|
|
22
|
|
86023
|
use Carp qw(croak); |
|
|
22
|
|
|
|
|
47
|
|
|
|
22
|
|
|
|
|
1218
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
22
|
|
|
22
|
|
112
|
use Moose::Util::TypeConstraints; |
|
|
22
|
|
|
|
|
34
|
|
|
|
22
|
|
|
|
|
187
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
22
|
|
|
22
|
|
35197
|
use namespace::clean -except => 'meta'; |
|
|
22
|
|
|
|
|
47
|
|
|
|
22
|
|
|
|
|
267
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with qw(KiokuDB::Backend::Serialize); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
requires "serialize_to_stream"; |
|
15
|
|
|
|
|
|
|
requires "deserialize_from_stream"; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my %types = ( |
|
18
|
|
|
|
|
|
|
storable => "KiokuDB::Serializer::Storable", |
|
19
|
|
|
|
|
|
|
json => "KiokuDB::Serializer::JSON", |
|
20
|
|
|
|
|
|
|
yaml => "KiokuDB::Serializer::YAML", |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
coerce( __PACKAGE__, |
|
24
|
|
|
|
|
|
|
from Str => via { |
|
25
|
|
|
|
|
|
|
my $class = $types{lc($_)} or croak "unknown format: $_";; |
|
26
|
|
|
|
|
|
|
Class::MOP::load_class($class); |
|
27
|
|
|
|
|
|
|
$class->new; |
|
28
|
|
|
|
|
|
|
}, |
|
29
|
|
|
|
|
|
|
from HashRef => via { |
|
30
|
|
|
|
|
|
|
my %args = %$_; |
|
31
|
|
|
|
|
|
|
my $class = $types{lc(delete $args{format})} or croak "unknown format: $args{format}"; |
|
32
|
|
|
|
|
|
|
Class::MOP::load_class($class); |
|
33
|
|
|
|
|
|
|
$class->new(%args); |
|
34
|
|
|
|
|
|
|
}, |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__PACKAGE__ |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=pod |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
KiokuDB::Serializer - Standalone serializer object |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Backend->new( |
|
50
|
|
|
|
|
|
|
serializer => KiokuDB::Serializer::Storable->new( ... ), |
|
51
|
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This role is for objects which perform the serialization roles (e.g. |
|
56
|
|
|
|
|
|
|
L<KiokuDB::Backend::Serialize::Storable>) but can be used independently. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This is used by L<KiokuDB::Backend::Serialize::Delegate> and |
|
59
|
|
|
|
|
|
|
L<KiokuDB::Cmd::DumpFormatter>. |