CGI-MxScreen

 view release on metacpan or  search on metacpan

MxScreen/Serializer/Storable.pm  view on Meta::CPAN

use Storable qw(freeze nfreeze thaw);

#
# ->make
#
# Creation routine.
#
# Arguments:
#   -shared		whether stored data can be read by various architectures
#   -compress	whether stored data should be compressed
#
sub make {
	DFEATURE my $f_;
	my $self = bless {}, shift;
	my ($shared, $compress) = xgetargs(@_,
		-shared		=> ['i', 0],
		-compress	=> ['i', 0],
	);

	my $freezer = $shared ? \&nfreeze : \&freeze;
	$self->_init($freezer, \&thaw, $compress);

	return DVAL $self;
}

1;

=head1 NAME

CGI::MxScreen::Serializer::Storable - Storable serialization

=head1 SYNOPSIS

 # Inherits from CGI::MxScreen::Serializer

 require CGI::MxScreen::Serializer::Storable;

 my $ser = CGI::MxScreen::Serializer::Storable->make(
     -shared     => 1,
     -compress   => 1,
 );

=head1 DESCRIPTION

This module customizes the serialization interface inherited from
C<CGI::MxScreen::Serializer> to use C<Storable>.

Apart from the creation routine documented hereinafter, this class
conforms to the interface described in L<CGI::MxScreen::Serializer>.

The creation routine C<make()> takes the following optional arguments:

=over 4

=item C<-compress> => I<flag>

Whether to compress the serialized form before returning it.
Data will be uncompressed on-the-fly by the C<deserialize> routine.
It is I<false> by default.

This makes compression transparent once configured.

=item C<-shared> => I<flag>

Whether serialized data are expected to be shared across different
architectures.  When I<true>, C<Storable> will use its portable format
to perform the serialization.  Otherwise, data can normally be recovered
only on a compatible architecture.

It is I<false> by default.

=back

=head1 AUTHOR

Raphael Manfredi F<E<lt>Raphael_Manfredi@pobox.comE<gt>>

=head1 SEE ALSO

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

=cut



( run in 1.794 second using v1.01-cache-2.11-cpan-39bf76dae61 )