CGI::MxScreen::Serializer - Abstract serializer interface
# 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);
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.
CGI::MxScreen::Serializer
freeze
thaw
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.
Compress::Zlib
Currently, the only serializer available is CGI::MxScreen::Serializer::Storable which is simply installing Storable.
CGI::MxScreen::Serializer::Storable
Storable
The following read-only attributes are defined. The are meant to be initialized at creation time via _init():
_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.
_init
This routine must be called by the make() routine in heirs to initialize the attributes.
make()
deserialize
Deserialize the frozen serialized string generated by serialize() and return a reference to its root object.
serialize()
serialize
Serialize the reference and return a string that can be deserialized by deserialize.
Raphael Manfredi <Raphael_Manfredi@pobox.com>
CGI::MxScreen::Serializer::Storable(3).
To install CGI::MxScreen, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::MxScreen
CPAN shell
perl -MCPAN -e shell install CGI::MxScreen
For more information on module installation, please visit the detailed CPAN module installation guide.