Session/Serialize/Storable.pm

filter: Statementstmt 100% 17 / 17 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 88.4% 23 / 26 CC 2 SCAR 2.9
CC
2
Cov
95%
unserialize
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Session/Generate/MD5.pm ↑ Summary Session/Serialize/UUEncode.pm »
1 #############################################################################
2 #
3 # Apache::Session::Serialize::Storable
4 # Serializes session objects using Storable
5 # Copyright(c) 2000 Jeffrey William Baker (jwbaker@acm.org)
6 # Distribute under the Perl License
7 #
8 ############################################################################
9
10 package Apache::Session::Serialize::Storable;
11
12 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use Storable qw(nfreeze thaw);
Subroutine BEGIN: called CC=1 SCAR=0.0
15
16 3 $VERSION = '1.01';
17
18 5 ▶sub serialize {
Subroutine serialize: called CC=1 SCAR=0.0
Pod undocumented
19 5 my $session = shift;
20
21 5 $session->{serialized} = nfreeze $session->{data};
22 }
23
24 2 ▶sub unserialize {
Subroutine unserialize: called CC=2 SCAR=7.0
Pod undocumented
25 2 my $session = shift;
26
27 2 my $data = thaw $session->{serialized};
28 2 ▶ die "Session could not be unserialized" unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 2 2
29 #Storable can return undef or die for different errors
30 2 $session->{data} = $data;
31 }
32
33 3 1;
34
35 =pod
36
37 =head1 NAME
38
39 Apache::Session::Serialize::Storable - Use Storable to zip up persistent data
40
41 =head1 SYNOPSIS
42
43 use Apache::Session::Serialize::Storable;
44
45 $zipped = Apache::Session::Serialize::Storable::serialize($ref);
46 $ref = Apache::Session::Serialize::Storable::unserialize($zipped);
47
48 =head1 DESCRIPTION
49
50 This module fulfills the serialization interface of Apache::Session.
51 It serializes the data in the session object by use of Storable's
52 C<nfreeze()> and C<thaw()> functions. The result is a binary object ready
53 for storage.
54
55 =head1 AUTHOR
56
57 This module was written by Jeffrey William Baker <jwbaker@acm.org>.
58
59 =head1 SEE ALSO
60
61 L<Apache::Session::Serialize::Base64>, L<Apache::Session>
« Session/Generate/MD5.pm ↑ Summary Session/Serialize/UUEncode.pm »