blib/lib/DBI/Gofer/Serializer/Storable.pm

filter: Statementstmt 74.1% 23 / 31 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 4 totaltotal 64.5% 31 / 48 CC 3 SCAR 5.0
CC
3
Cov
69%
serialize
2.7
serialize
2.7
deserialize
1.1
CRAP 1.6
« blib/lib/DBI/Util/CacheMemory.pm ↑ Summary blib/lib/DBD/Gofer/Policy/Base.pm »
1 package DBI::Gofer::Serializer::Storable;
2  
3 63 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 63 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 63 ▶use base qw(DBI::Gofer::Serializer::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
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<DBI::Gofer::Serializer::Base>.
36  
37 =cut
38  
39 63 ▶use Storable qw(nfreeze thaw);
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 our $VERSION = "0.015586";
42  
43 63 ▶use base qw(DBI::Gofer::Serializer::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45  
46 13897 ▶sub serialize {
Subroutine serialize: called CC=2 SCAR=10.0
Pod undocumented
47 0 ▶ my $self = shift;
Subroutine serialize: not called CC=2 SCAR=10.0
Pod undocumented
48 0 local $Storable::forgive_me = 1; # for CODE refs etc
49 0 local $Storable::canonical = 1; # for go_cache
50 0 my $frozen = nfreeze(shift);
51 0 ▶ return $frozen unless wantarray;
Branch: 2 branches
BranchTrueFalseTotal
unless wantarray 0 0 0
unless wantarray 0 13897 13897
52 0 return ($frozen, $self->{deserializer_class});
53 }
54  
55 13883 ▶sub deserialize {
Subroutine deserialize: called CC=1 SCAR=1.2
Pod undocumented
56 0 ▶ my $self = shift;
Subroutine deserialize: not called CC=1 SCAR=1.2
Pod undocumented
57 0 return thaw(shift);
58 }
59  
60 1;
« blib/lib/DBI/Util/CacheMemory.pm ↑ Summary blib/lib/DBD/Gofer/Policy/Base.pm »