.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "KiokuDB::TypeMap::Composite 3pm" .TH KiokuDB::TypeMap::Composite 3pm "2022-05-23" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" KiokuDB::TypeMap::Composite \- A role for KiokuDB::TypeMaps created out of many smaller typemaps .SH "VERSION" .IX Header "VERSION" version 0.57 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& package MyTypeMap; \& use Moose; \& \& extends qw(KiokuDB::TypeMap); \& \& with qw(KiokuDB::TypeMap::Composite); \& \& \& # declare typemaps to inherit from using the KiokuDB::TypeMap trait \& # the \*(Aqincludes\*(Aq 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 => \*(AqKiokuDB::TypeMap::Entry::Callback\*(Aq, \& 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, \& }, \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This role provides a declarative, customizable way to set values for KiokuDB::TypeMap's \f(CW\*(C`includes\*(C'\fR attribute. .PP Any class consuming this role can declare attributes with the trait \&\f(CW\*(C`KiokuDB::TypeMap\*(C'\fR. .PP 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. .PP KiokuDB::TypeMap::Default is created using this role. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .IP "exclude" 4 .IX Item "exclude" An array reference containing typemap attribute names (e.g. \f(CW\*(C`path_class\*(C'\fR in the default typemap) or class name to exclude. .Sp Class exclusions are handled by \f(CW\*(C`_create_typemap\*(C'\fR and do not apply to already constructed typemaps. .IP "override" 4 .IX Item "override" A hash reference of classes to KiokuDB::TypeMap::Entry objects. .Sp Class overrides are handled by \f(CW\*(C`_create_typemap\*(C'\fR and do not apply to already constructed typemaps. .Sp 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. .SH "METHODS" .IX Header "METHODS" .ie n .IP "_create_typemap %args" 4 .el .IP "_create_typemap \f(CW%args\fR" 4 .IX Item "_create_typemap %args" Creates a new typemap. .Sp The entry arguments are converted before passing to \*(L"new\*(R" in KiokuDB::TypeMap: .Sp .Vb 8 \& $self\->_create_typemap( \& entries => { \& Foo => { \& type => "KiokuDB::TypeMap::Entry::Naive", \& intrinsic => 1, \& }, \& }, \& ); .Ve .Sp The nested hashref will be used as arguments to \&\*(L"new\*(R" in KiokuDB::TypeMap::Entry::Naive in this example. .Sp \&\f(CW\*(C`exclude\*(C'\fR and \f(CW\*(C`override\*(C'\fR are taken into account by the hashref conversion code. .ie n .IP "_naive_isa_typemap $class, %entry_args" 4 .el .IP "_naive_isa_typemap \f(CW$class\fR, \f(CW%entry_args\fR" 4 .IX Item "_naive_isa_typemap $class, %entry_args" A convenience method to create a one entry typemap with a single inherited entry for \f(CW$class\fR of the type KiokuDB::TypeMap::Entry::Naive. .Sp This is useful for when you have a base class that you'd like KiokuDB to persist automatically: .Sp .Vb 3 \& sub _build_my_class_typemap { \& shift\->_naive_isa_typemap( "My::Class::Base" ); \& } .Ve .SH "AUTHOR" .IX Header "AUTHOR" Yuval Kogman .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2014 by Yuval Kogman, Infinity Interactive. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.