File Coverage

blib/lib/DBI/Gofer/Serializer/Base.pm
Criterion Covered Total %
statement 16 20 80.0
branch n/a
condition 1 3 33.3
subroutine 5 7 71.4
pod 0 4 0.0
total 22 34 64.7


line stmt bran cond sub pod time code
1             package DBI::Gofer::Serializer::Base;
2              
3             # $Id: Base.pm 9949 2007-09-18 09:38:15Z Tim $
4             #
5             # Copyright (c) 2007, Tim Bunce, Ireland
6             #
7             # You may distribute under the terms of either the GNU General Public
8             # License or the Artistic License, as specified in the Perl README file.
9              
10             =head1 NAME
11              
12             DBI::Gofer::Serializer::Base - base class for Gofer serialization
13              
14             =head1 SYNOPSIS
15              
16             $serializer = $serializer_class->new();
17              
18             $string = $serializer->serialize( $data );
19             ($string, $deserializer_class) = $serializer->serialize( $data );
20              
21             $data = $serializer->deserialize( $string );
22              
23             =head1 DESCRIPTION
24              
25             DBI::Gofer::Serializer::* classes implement a very minimal subset of the L API.
26              
27             Gofer serializers are expected to be very fast and are not required to deal
28             with anything other than non-blessed references to arrays and hashes, and plain scalars.
29              
30             =cut
31              
32              
33 56     56   334 use strict;
  56         99  
  56         1259  
34 56     56   230 use warnings;
  56         95  
  56         1263  
35              
36 56     56   243 use Carp qw(croak);
  56         97  
  56         10695  
37              
38             our $VERSION = "0.009950";
39              
40              
41             sub new {
42 715     715 0 1530 my $class = shift;
43 715         2009 my $deserializer_class = $class->deserializer_class;
44 715         3665 return bless { deserializer_class => $deserializer_class } => $class;
45             }
46              
47             sub deserializer_class {
48 715     715 0 1327 my $self = shift;
49 715   33     2762 my $class = ref($self) || $self;
50 715         3207 $class =~ s/^DBI::Gofer::Serializer:://;
51 715         1985 return $class;
52             }
53              
54             sub serialize {
55 0     0 0   my $self = shift;
56 0           croak ref($self)." has not implemented the serialize method";
57             }
58              
59             sub deserialize {
60 0     0 0   my $self = shift;
61 0           croak ref($self)." has not implemented the deserialize method";
62             }
63              
64             1;