line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBI::Gofer::Serializer::Storable; |
2
|
|
|
|
|
|
|
|
3
|
56
|
|
|
56
|
|
291
|
use strict; |
|
56
|
|
|
|
|
980
|
|
|
56
|
|
|
|
|
1312
|
|
4
|
56
|
|
|
56
|
|
235
|
use warnings; |
|
56
|
|
|
|
|
91
|
|
|
56
|
|
|
|
|
1331
|
|
5
|
|
|
|
|
|
|
|
6
|
56
|
|
|
56
|
|
250
|
use base qw(DBI::Gofer::Serializer::Base); |
|
56
|
|
|
|
|
102
|
|
|
56
|
|
|
|
|
13684
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# $Id: Storable.pm 15585 2013-03-22 20:31:22Z Tim $ |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Copyright (c) 2007, Tim Bunce, Ireland |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public |
13
|
|
|
|
|
|
|
# License or the Artistic License, as specified in the Perl README file. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
DBI::Gofer::Serializer::Storable - Gofer serialization using Storable |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$serializer = DBI::Gofer::Serializer::Storable->new(); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$string = $serializer->serialize( $data ); |
24
|
|
|
|
|
|
|
($string, $deserializer_class) = $serializer->serialize( $data ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$data = $serializer->deserialize( $string ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Uses Storable::nfreeze() to serialize and Storable::thaw() to deserialize. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The serialize() method sets local $Storable::forgive_me = 1; so it doesn't |
33
|
|
|
|
|
|
|
croak if it encounters any data types that can't be serialized, such as code refs. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
See also L. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
56
|
|
|
56
|
|
13619
|
use Storable qw(nfreeze thaw); |
|
56
|
|
|
|
|
77019
|
|
|
56
|
|
|
|
|
3848
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our $VERSION = "0.015586"; |
42
|
|
|
|
|
|
|
|
43
|
56
|
|
|
56
|
|
327
|
use base qw(DBI::Gofer::Serializer::Base); |
|
56
|
|
|
|
|
103
|
|
|
56
|
|
|
|
|
5312
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub serialize { |
47
|
13689
|
|
|
13689
|
0
|
18946
|
my $self = shift; |
48
|
13689
|
|
|
|
|
20734
|
local $Storable::forgive_me = 1; # for CODE refs etc |
49
|
13689
|
|
|
|
|
19563
|
local $Storable::canonical = 1; # for go_cache |
50
|
13689
|
|
|
|
|
31503
|
my $frozen = nfreeze(shift); |
51
|
13689
|
50
|
|
|
|
940095
|
return $frozen unless wantarray; |
52
|
13689
|
|
|
|
|
47833
|
return ($frozen, $self->{deserializer_class}); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub deserialize { |
56
|
13675
|
|
|
13675
|
0
|
19314
|
my $self = shift; |
57
|
13675
|
|
|
|
|
31019
|
return thaw(shift); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |