[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 package DBI::Gofer::Serializer::Storable; 2 3 use strict; 4 use warnings; 5 6 use base qw(DBI::Gofer::Serializer::Base); 7 8 # $Id: Storable.pm 9949 2007-09-18 09:38:15Z timbo $ 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 use Storable qw(nfreeze thaw); 40 41 our $VERSION = sprintf("0.%06d", q$Revision: 9949 $ =~ /(\d+)/o); 42 43 use base qw(DBI::Gofer::Serializer::Base); 44 45 46 sub serialize { 47 my $self = shift; 48 local $Storable::forgive_me = 1; # for CODE refs etc 49 my $frozen = nfreeze(shift); 50 return $frozen unless wantarray; 51 return ($frozen, $self->{deserializer_class}); 52 } 53 54 sub deserialize { 55 my $self = shift; 56 return thaw(shift); 57 } 58 59 1;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |