Catmandu::Addable - Base class for all Catmandu modules need to implement add
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;
Autocommit when the exporter gets out of scope. Default 0.
Receives a Perl hash and should return true or false.
This method is usually called at the end of many add or add_many operations.
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.
Catmandu::Fixable, Catmandu::Exporter , Catmandu::Store
To install Catmandu, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catmandu
CPAN shell
perl -MCPAN -e shell install Catmandu
For more information on module installation, please visit the detailed CPAN module installation guide.