[libcatmandu-perl] 25/46: Adding POD for Addable

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 ce500e1c701b49911b93363e9a9ea58070c498e8
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Wed Sep 24 16:31:07 2014 +0200

    Adding POD for Addable
---
 lib/Catmandu/Addable.pm  | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/Catmandu/Iterator.pm |  2 +-
 2 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/lib/Catmandu/Addable.pm b/lib/Catmandu/Addable.pm
index 7f47798..5bcde6a 100644
--- a/lib/Catmandu/Addable.pm
+++ b/lib/Catmandu/Addable.pm
@@ -46,4 +46,68 @@ sub add_many {
 
 sub commit {}
 
+=head1 NAME
+
+Catmandu::Addable - Base class for all Catmandu modules need to implement add
+
+=head1 SYNOPSIS
+
+    package My::Adder;
+
+    use Moo;
+    use Data::Dumper;
+  
+    with 'Catmandu::Addable';
+
+    sub add {
+        my ($self,$object) = @_;
+
+        print "So you want to add:\n";
+        print Dumper($object);
+
+        1;
+    }
+
+    sub commit {
+        my $self = shift;
+
+        print "And now you are done?\n";
+    }
+
+    package main;
+
+    my $adder = My::Adder->new(fix => ['upcase(foo)']);
+
+    # prints foo => BAR
+    $adder->add({ foo => 'bar' });
+    
+    # prints:
+    #  foo => BAR
+    #  foo => BAR
+    $adder->add_many([ { foo => 'bar' } , { foo => 'bar' }]);
+
+    # prints a commit statement
+    $adder->commit;
+
+=head1 METHODS
+
+=head2 add($hash)
+
+Receives a Perl hash and should return true or false.
+
+=head2 commit
+
+This method is usually called at the end of many add or add_many operations.
+
+=head1 INHERIT
+
+If you provide an 'add' method, then automatically your package gets a add_many method, plus
+a fix attribute which transforms all Perl hashes provided to the add method.
+
+=head1 SEE ALSO
+
+L<Catmandu::Fixable>, L<Catmandu::Exporter> , L<Catmandu::Store>
+
+=cut
+
 1;
diff --git a/lib/Catmandu/Iterator.pm b/lib/Catmandu/Iterator.pm
index a9e51d4..04a1029 100644
--- a/lib/Catmandu/Iterator.pm
+++ b/lib/Catmandu/Iterator.pm
@@ -47,7 +47,7 @@ Catmandu::Iterator - Base class for all Catmandu iterators
 
   my $it2 = $it->map(sub { shift->{random} * 2 });
 
-=head1 METHOD
+=head1 METHODS
 
 =head2 generator
 

-- 
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