Catmandu::Addable(3pm)

Catmandu::Addable3pm

Base class for all catmandu modules need to implement add

Usage

    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;

Options

autocommit

Autocommit when the exporter gets out of scope. Default 0.

Methods

add($hash)

Receives a Perl hash and should return true or false.

commit

This method is usually called at the end of many add or add_many operations.

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.

Releases

6 releases since Debian 8 (Jessie); the text changed 5 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13

From libcatmandu-perl 1.2024-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.