Catman...Addable(3pm)
π Catmandu::Addable β the base class glow-up β¨
okay bestie, so this is Catmandu::Addable, and it's giving base class energy π
β like, it's the blueprint for every Catmandu module that needs to implement add. That's the whole point of it. It's Catman...Addable(3pm) in the manual, but we're on a first-name basis here. π
πΈ SYNOPSIS πΈ
here's the whole vibe, in code, no notes:
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;
like, look at it. iconic. π
β¨ OPTIONS β¨
autocommitβ autocommit moment when the exporter gets out of scope π«Ά. Default is0.
π¦ METHODS π¦
add($hash)
hands you a Perl hash and expects you to return true or false, fr fr. that's the deal. π
commit
this one is usually called at the end of a whole bunch of add or add_many operations. it's the lil "we're done here" at the end of the party. π
π« INHERIT π«
the way that this just works: if you provide an add method, then automatically your package gets an add_many method, plus a fix attribute which transforms all the Perl hashes that get provided to the add method. free stuff. we love free stuff. π
π SEE ALSO π
Catmandu::FixableCatmandu::ExporterCatmandu::Store
go read them, iykyk πβ¨
okay that's the whole page, bestie, and now the cute sign-off π: this one's from perl v5.40.1, dated 2026-01-24, and it lives in the manual as Catman...Addable(3pm). periodt. ππ
π¦ where this page comes from
- ubuntu resolute: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms