[libcatmandu-perl] 29/46: Adding POD for Catmandu::Serializer

Jonas Smedegaard dr at jones.dk
Tue Oct 14 13:52:53 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.9205
in repository libcatmandu-perl.

commit be3019ef5208d18e3c32593000f218ac4d336edc
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Fri Sep 26 13:30:20 2014 +0200

    Adding POD for Catmandu::Serializer
---
 lib/Catmandu/Serializer.pm | 59 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/lib/Catmandu/Serializer.pm b/lib/Catmandu/Serializer.pm
index b98eb16..98f7b37 100644
--- a/lib/Catmandu/Serializer.pm
+++ b/lib/Catmandu/Serializer.pm
@@ -25,4 +25,63 @@ sub _build_serializer {
     $pkg->new;
 }
 
+# Needs to be implemeted by a serializer
+sub serialize {}
+
+# Needs to be implemeted by a serializer
+sub deserialize {}
+
+=head1 NAME
+
+Catmandu::Serializer - Base class for all Catmandu Serializers
+
+=head1 SYNOPSIS
+
+    package Catmandu::Serializer::Foo;
+
+    use Moo;
+
+    sub serialize {
+        my ($self,$data) = @_;
+        .. transform the data to a string and return it...
+    }
+
+    sub deserialize {
+        my ($self,$string) = @_;
+        ... transform the string into a perl hash ...
+    }
+
+    package MyPackage;
+
+    use Moo;
+
+    with 'Catmandu::Serializer';
+
+    package main;
+
+    my $pkg = MyPackage->new;
+
+    my $string = $pkg->serialize({ foo => 'bar' });
+    my $perl   = $pkg->deserialize($string);
+
+    # Using Catmandu::Serializer::Foo 
+    my $pkg = MyPackage->new( serialize => 'Foo' );
+
+    my $string = $pkg->serialize({ foo => 'bar' });
+    my $perl   = $pkg->deserialize($string);
+	
+=head1 DESCRIPTION
+
+This is a convience class to send Perl hashes easily over the wire without having to
+instantiate a L<Catmandu::Importer> and L<Catmandu::Exporter> which are more suited for
+processing IO streams.
+
+=head1 SEE ALSO
+
+L<Catmandu::Store::DBI>, 
+L<Catmandu::Serializer::json>,
+L<Catmandu::Serializer::storabe>,
+L<Catmandu::Serializer::messagepack>
+
+=cut
 1;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git



More information about the Pkg-perl-cvs-commits mailing list