MxScreen/Serializer/Storable.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 37 CC 2 SCAR 11.0
CC
2
Cov
0%
make
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.0
1 # -*- Mode: perl -*-
2 #
3 # $Id: Storable.pm,v 0.1 2001/04/22 17:57:03 ram Exp $
4 #
5 # Copyright (c) 1998-2001, Raphael Manfredi
6 # Copyright (c) 2000-2001, Christophe Dehaudt
7 #
8 # You may redistribute only under the terms of the Artistic License,
9 # as specified in the README file that comes with the distribution.
10 #
11 # HISTORY
12 # $Log: Storable.pm,v $
13 # Revision 0.1 2001/04/22 17:57:03 ram
14 # Baseline for first Alpha release.
15 #
16 # $EndLog$
17 #
18  
19 use strict;
20  
21 package CGI::MxScreen::Serializer::Storable;
22  
23 require CGI::MxScreen::Serializer;
24 use vars qw(@ISA);
25 @ISA = qw(CGI::MxScreen::Serializer);
26  
27 use Carp::Datum;
28 use Getargs::Long;
29 use Storable qw(freeze nfreeze thaw);
30  
31 #
32 # ->make
33 #
34 # Creation routine.
35 #
36 # Arguments:
37 # -shared whether stored data can be read by various architectures
38 # -compress whether stored data should be compressed
39 #
40 sub make {
41 DFEATURE my $f_;
42 my $self = bless {}, shift;
43 my ($shared, $compress) = xgetargs(@_,
44 -shared => ['i', 0],
45 -compress => ['i', 0],
46 );
47  
48 my $freezer = $shared ? \&nfreeze : \&freeze;
49 $self->_init($freezer, \&thaw, $compress);
50  
51 return DVAL $self;
52 }
53  
54 1;
55  
56 =head1 NAME
57  
58 CGI::MxScreen::Serializer::Storable - Storable serialization
59  
60 =head1 SYNOPSIS
61  
62 # Inherits from CGI::MxScreen::Serializer
63  
64 require CGI::MxScreen::Serializer::Storable;
65  
66 my $ser = CGI::MxScreen::Serializer::Storable->make(
67 -shared => 1,
68 -compress => 1,
69 );
70  
71 =head1 DESCRIPTION
72  
73 This module customizes the serialization interface inherited from
74 C<CGI::MxScreen::Serializer> to use C<Storable>.
75  
76 Apart from the creation routine documented hereinafter, this class
77 conforms to the interface described in L<CGI::MxScreen::Serializer>.
78  
79 The creation routine C<make()> takes the following optional arguments:
80  
81 =over 4
82  
83 =item C<-compress> => I<flag>
84  
85 Whether to compress the serialized form before returning it.
86 Data will be uncompressed on-the-fly by the C<deserialize> routine.
87 It is I<false> by default.
88  
89 This makes compression transparent once configured.
90  
91 =item C<-shared> => I<flag>
92  
93 Whether serialized data are expected to be shared across different
94 architectures. When I<true>, C<Storable> will use its portable format
95 to perform the serialization. Otherwise, data can normally be recovered
96 only on a compatible architecture.
97  
98 It is I<false> by default.
99  
100 =back
101  
102 =head1 AUTHOR
103  
104 Raphael Manfredi F<E<lt>Raphael_Manfredi@pobox.comE<gt>>
105  
106 =head1 SEE ALSO
107  
108 CGI::MxScreen::Serializer(3), Storable(3).
109  
110 =cut
111