Jason Purdy > CGI-MxScreen > CGI::MxScreen::Serializer

Download:
CGI-MxScreen-0.103.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

CGI::MxScreen::Serializer - Abstract serializer interface

SYNOPSIS ^

 # Deferred class, only heirs may be instantiated

 # In heirs:
 use base qw(CGI::MxScreen::Serializer);

 sub make {             # define the creation routine
     ...
     $self->_init(\&freeze, \&thaw, $compress);
 }

 # Access interface - $ser is an instantiated heir
 my $serialized   = $ser->serialize($ref);
 my $deserialized = $ser->deserialize($serialized);

DESCRIPTION ^

This module implements a serializer abstraction and should probably be a CPAN module of its own. I'm seriously thinking about it.

The CGI::MxScreen::Serializer class is deferred. The only thing it lacks is a creation routine, which will initialize the freeze and thaw attributes with code references to the proper freezing and thawing routines.

It bluntly assumes those routine will conform to the following signatures:

    freeze(x: REF): STRING
    thaw(x: STRING): REF

and satisfy the following condition, for every x:

    thaw(freeze(x)).deep_equal(x)

where deep_equal is an operation testing that its arguments are structurally equivalent, whatever that means.

This class also supports on-the-fly compression and decompression of the serialized data via Compress::Zlib.

SUPPORTED SERIALIZERS ^

Currently, the only serializer available is CGI::MxScreen::Serializer::Storable which is simply installing Storable.

INTERFACE ^

Attributes

The following read-only attributes are defined. The are meant to be initialized at creation time via _init():

compress

A boolean flag, stating whether Compress::Zlib compression and decompression should be performed.

freezer

A CODE reference on the freezing routine.

thawer

A CODE reference on the thawing routine.

Routines

_init freezer, thawer, compress_flag

This routine must be called by the make() routine in heirs to initialize the attributes.

deserialize frozen

Deserialize the frozen serialized string generated by serialize() and return a reference to its root object.

serialize reference

Serialize the reference and return a string that can be deserialized by deserialize.

AUTHOR ^

Raphael Manfredi <Raphael_Manfredi@pobox.com>

SEE ALSO ^

CGI::MxScreen::Serializer::Storable(3).

syntax highlighting: