Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

kiokudb::typemap::entry::callback(3pm) [debian man page]

KiokuDB::TypeMap::Entry::Callback(3pm)			User Contributed Perl Documentation		    KiokuDB::TypeMap::Entry::Callback(3pm)

NAME
KiokuDB::TypeMap::Entry::Callback - Callback based inflation/deflation of objects 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 ), }, ); DESCRIPTION
This KiokuDB::TypeMap entry provides callback based inflation/deflation. The major limitation of this method is that it cannot be used for self referential structures. This is because the object being inflated is only constructed after all of its arguments are. For the overwhelming majority of the use cases this is good enough though. ATTRIBUTES
collapse A method name or code reference invoked on the object during collapsing. This is evaluated in list context, and the list of values it returns will be collapsed by the KiokuDB::Collapser and then stored. expand A method name or code reference invoked on the class of the object during loading. The arguments are as returned by the "collapse" callback. id An optional method name or code reference invoked to get an ID for the object. If one is not provided the default (UUID based) generation is used. intrinsic A boolean denoting whether or not the object should be collapsed with no ID, and serialized as part of its parent object. This is useful for value like objects, for whom the reference address makes no difference (such as URI objects). perl v5.12.4 2010-10-11 KiokuDB::TypeMap::Entry::Callback(3pm)

Check Out this Related Man Page

KiokuDB::TypeMap::Composite(3pm)			User Contributed Perl Documentation			  KiokuDB::TypeMap::Composite(3pm)

NAME
KiokuDB::TypeMap::Composite - A role for KiokuDB::TypeMaps created out of many smaller typemaps SYNOPSIS
package MyTypeMap; use Moose; extends qw(KiokuDB::TypeMap); with qw(KiokuDB::TypeMap::Composite); # declare typemaps to inherit from using the KiokuDB::TypeMap trait # the 'includes' attribute will be built by collecting these attrs: has foo_typemap => ( traits => [qw(KiokuDB::TypeMap)], # register for inclusion does => "KiokUDB::Role::TypeMap", is => "ro", lazy_build => 1, ); # this role also provides convenience methods for creating typemap objects # easily: sub _build_foo_typemap { my $self = shift; $self->_create_typemap( isa_entries => { $class => { type => 'KiokuDB::TypeMap::Entry::Callback', intrinsic => 1, collapse => "collapse", expand => "new", }, }, ); } sub _build_bar_typemap { my $self = shift; # create a typemap with one naive isa entry $self->_naive_isa_typemap("Class::Foo", @entry_args); } # you also get some construction time customization: MyTypeMap->new( exclude => [qw(Class::Blort foo)], override => { "Class::Blah", => $alternate_entry, }, ); DESCRIPTION
This role provides a declarative, customizable way to set values for KiokuDB::TypeMap's "includes" attribute. Any class consuming this role can declare attributes with the trait "KiokuDB::TypeMap". The result is a typemap instance that inherits from the specified typemap in a way that is composable for the author and flexible for the user. KiokuDB::TypeMap::Default is created using this role. ATTRIBUTES
exclude An array reference containing typemap attribute names (e.g. "path_class" in the default typemap) or class name to exclude. Class exclusions are handled by "_create_typemap" and do not apply to already constructed typemaps. override A hash reference of classes to KiokuDB::TypeMap::Entry objects. Class overrides are handled by "_create_typemap" and do not apply to already constructed typemaps. Classes which don't have a definition will not be merged into the resulting typemap, simply create a typemap of your own and inherit if that's what you want. METHODS
_create_typemap %args Creates a new typemap. The entry arguments are converted before passing to "new" in KiokuDB::TypeMap: $self->_create_typemap( entries => { Foo => { type => "KiokuDB::TypeMap::Entry::Naive", intrinsic => 1, }, }, ); The nested hashref will be used as arguments to "new" in KiokuDB::TypeMap::Entry::Naive in this example. "exclude" and "override" are taken into account by the hashref conversion code. _naive_isa_typemap $class, %entry_args A convenience method to create a one entry typemap with a single inherited entry for $class of the type KiokuDB::TypeMap::Entry::Naive. This is useful for when you have a base class that you'd like KiokuDB to persist automatically: sub _build_my_class_typemap { shift->_naive_isa_typemap( "My::Class::Base" ); } perl v5.12.4 2010-10-11 KiokuDB::TypeMap::Composite(3pm)
Man Page