Data-FlexSerializer
view release on metacpan or search on metacpan
lib/Data/FlexSerializer.pm view on Meta::CPAN
Whether we should detect this incoming format. By default only
C<detect_json> is true. You can also set C<detect_storable>,
C<detect_sereal> or C<detect_YOUR_FORMAT> for formats added via
L</add_format>.
=head2 sereal_encoder
=head2 sereal_decoder
You can supply C<sereal_encoder> or C<sereal_decoder> arguments with
your own Serial decoder/encoder objects. Handy if you want to pass
custom options to the encoder or decoder.
By default we create objects for you at BUILD time. So you don't need
to supply this for optimization purposes either.
=head1 METHODS
=head2 serialize
Given a list of things to serialize, this does the job on each of them and
returns a list of serialized blobs.
In scalar context, this will return a single serialized blob instead of a
list. If called in scalar context, but passed a list of things to serialize,
this will croak because the call makes no sense.
=head2 deserialize
The opposite of C<serialize>, doh.
=head2 deserialize_from_file
Given a (single!) file name, reads the file contents and deserializes them.
Returns the resulting Perl data structure.
Since this works on one file at a time, this doesn't return a list of
data structures like C<deserialize()> does.
=head2 serialize_to_file
$serializer->serialize_to_file(
$data_structure => '/tmp/foo/bar'
);
Given a (single!) Perl data structure, and a (single!) file name,
serializes the data structure and writes the result to the given file.
Returns true on success, dies on failure.
=head1 CLASS METHODS
=head2 add_format
C<add_format> class method to add support for custom formats.
Data::FlexSerializer->add_format(
data_dumper => {
serialize => sub { shift; goto \&Data::Dumper::Dumper },
deserialize => sub { shift; my $VAR1; eval "$_[0]" },
detect => sub { $_[1] =~ /\$[\w]+\s*=/ },
}
);
my $flex_to_dd = Data::FlexSerializer->new(
detect_data_dumper => 1,
output_format => 'data_dumper',
);
=head1 AUTHOR
Steffen Mueller <smueller@cpan.org>
Ãvar Arnfjörð Bjarmason <avar@cpan.org>
Burak Gürsoy <burak@cpan.org>
Elizabeth Matthijsen <liz@dijkmat.nl>
Caio Romão Costa Nascimento <cpan@caioromao.com>
Jonas Galhordas Duarte Alves <jgda@cpan.org>
=head1 ACKNOWLEDGMENT
This module was originally developed at and for Booking.com.
With approval from Booking.com, this module was generalized
and put on CPAN, for which the authors would like to express
their gratitude.
=head1 COPYRIGHT AND LICENSE
(C) 2011, 2012, 2013 Steffen Mueller and others. All rights reserved.
This code is available under the same license as Perl version
5.8.1 or higher.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=cut
( run in 1.774 second using v1.01-cache-2.11-cpan-5735350b133 )