KiokuD...allback(3pm)
π KiokuDB::TypeMap::Entry::Callback π
okay bestie, welcome to the User Contributed Perl Documentation glow-up of KiokuDB::TypeMap::Entry::Callback(3pm) β the type map entry that does inflation and deflation of objects through callbacks. yes, callbacks. we love a pluggable moment. β¨
πΈ VERSION πΈ
version 0.57 β she's giving vintage but she works, no cap.
π¦ SYNOPSIS π¦
KiokuDB::TypeMap->new(
entries => {
'My::Class' => KiokuDB::TypeMap::Entry::Callback->new(
expand => "new", # My::Class->new(%$self)
collapse => sub {
my $self = shift;
return %$self; # provide args to 'new' in this example
},
id => sub { "foo" }, # 'id' callback is optional
),
},
);
look at that. clean. iconic. she's basically saying "here's how you turn an object into a list and back again, you're welcome." π«Ά
β¨ DESCRIPTION β¨
So this KiokuDB::TypeMap entry provides callback based inflation and deflation. That's the whole vibe. You hand her some callbacks, she hands you objects back. π
β οΈ But bestie, listen β the major limitation here is that this method cannot be used for self referential structures. Why? Because the object being inflated is only constructed after all of its arguments are. So likeβ¦ the object can't reference itself while it doesn't exist yet. it's giving "can't sit with us, you're not built yet." π
For the overwhelming majority of the use cases though? This is good enough. fr fr. π
π ATTRIBUTES π
collapseβ a method name or code reference that gets invoked on the object during collapsing. She's evaluated in list context, and that list of values she returns gets collapsed by theKiokuDB::Collapserand then stored. πexpandβ a method name or code reference invoked on the class of the object during loading. The arguments are exactly as returned by thecollapsecallback. symmetry, we love to see it. πidβ an optional method name or code reference invoked to get an ID for the object. If you don't provide one, the default (UUID based) generation is used. she'll handle it, don't stress. πintrinsicβ a boolean denoting whether or not the object should be collapsed with no ID, and serialized as part of its parent object. Super useful for value like objects, for whom the reference address makes no difference β such asURIobjects. main character energy for value objects. π§
π AUTHOR π
Yuval Kogman <nothingmuch@woobling.org> β the legend herself. π«Ά
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2014 by Yuval Kogman, Infinity Interactive.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so go off, legally. β
and that's the whole page, bestie β perl v5.34.0, dated 2022-05-23, KiokuDB::TypeMap::Entry::Callback, signing off. mwah. π
π¦ where this page comes from
- debian bookworm: libkiokudb-perl 0.57-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libkiokudb-perl 0.57-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libkiokudb-perl 0.57-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libkiokudb-perl 0.57-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms