Why not adopt me?
NAME
Search::GIN::Extract::ClassMap::Role - A base role for maps containing classes and associated handlers.
VERSION
version 1.000003
SYNOPSIS
{
package Foo;
use MooseX::Role;
with 'Search::GIN::Extract::ClassMap::Role';
sub matches {
my ( $self, $extractee ) = @_;
my @m;
for ( $self->classmap_entries ) {
if( $extractee->some_criteria( $_ ) ) {
push @m, $self->classmap_get( $_ );
}
}
return @m;
}
}
REQUIRED METHODS
matches
my ( @extractors ) = $item->matches( $extractee )
Must take an object and return a list of Search::GIN::Extract
items to use for it.
for my $extractor ( @extractors ) {
my $metadata = $extractor->extract_values( $extractee );
}
METHODS
classmap_entries
my ( @classnames ) = $item->classmap_entries();
Fetches the Class
names ( keys
) for all registered handlers in this instance. ( Accessor for classmap
)
classmap_set
$item->classmap_set( $classname, $handler );
Sets the handler for class $classname
in this instance. ( Setter for classmap
)
classmap_get
$item->classmap_get( $classname );
Gets the handler for class $classname
in this instance. ( Getter for classmap
)
extract_values
my @values = $instance->extract_values( $extractee );
extracts values from all matching rules for the object
ATTRIBUTES
classmap
my $item = Thing::That::Does::ClassMap::Role->new(
classmap => {
classname => handler_for_objects_of_classname
}
);
# or
$item->classmap( classmap => { ... } );
This is a key => value pair set mapping classes to some Extractor to use for that class
$item->classmap_entries # class names / keys
$item->classmap_set( $classname, $handler );
my $handler = $item->classmap_get( $classname );
isa
:CoercedClassMap
coerce
:True
provides
:
AUTHOR
Kent Fredric <kentnl@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.