Search::GIN::Extract::ClassMap - Delegate Extraction based on class.
version 1.000004
my $extractor = Search::GIN::Extract::ClassMap->new(
extract_isa => {
'Foo' => [qw( bar baz quux )],
'Bar' => Search::GIN::Extract::AttributeIndex->new(),
'Baz' => sub { shift; my $object = shift; { a => $object->a() } },
},
extract_does => {
},
extract => {
/* either ISA or DOES */
},
);
In reality, the form is more like this:
my $extractor = Search::GIN::Extract::ClassMap->new(
extract_isa => {
'Foo' => Search::GIN::Extract::*,
'Bar' => Search::GIN::Extract::*,
'Baz' => Search::GIN::Extract::*,
},
extract_does => {
},
extract => {
/* either ISA or DOES */
},
);
With the minor exception of the 2 exception cases, passing
an ArrayRef
, or a CodeRef
, which internally are type-cast to
Search::GIN::Extract::Attributes
and Search::GIN::Extract::Callback
automatically.
This is an early release, API
is prone to change without much warning, but best attempts will be made to avoid the need.
This module is an extension for the Search::GIN
framework
providing a novel way to dictate which attribute extraction techniques will be
used for which object by having rules that map against the objects inheritance
or the objects composed roles.
This essentially permits you to register adapters for various object types to special-case their extraction.
For example, if you had a source tree that used classes under your control
using MooseX::AttributeIndexes
, you could easily default those classes to
extract using Search::GIN::Extract::AttributeIndexes
. And if any objects of
those classes had DateTime
properties, you could define a handler for
extracting DateTime
meta-data for indexing specifically.
my ( @values ) = $object->extract_values( $extractee );
for: Search::GIN::Extract
Iterates the contents of the extract($|_\w+$)
rules, and asks them to
extract their respective information, and returns the resulting results as a
list.
my $object = Search::GIN::Extract::ClassMap->new(
extract_isa => $isa_thing
);
# or
$object->extract_isa( $isa_thing )
Applied on all objects where $object->isa( $classname );
-
HashRef[ [Extractor](https://metacpan.org/pod/Search::GIN::Extract::ClassMap::Types#Extractor) ]
-
HashRef
's are automatically type-cast.
my $object = Search::GIN::Extract::ClassMap->new(
extract_does => $does_thing
);
# or
$object->extract_does( $does_thing );
Applied on all objects where $object->does( $classname );
-
HashRef[ [Extractor](https://metacpan.org/pod/Search::GIN::Extract::ClassMap::Types#Extractor) ]
-
HashRef
's are automatically type-cast.
my $object = Search::GIN::Extract::ClassMap->new(
extract => $like_thing
);
# or
$object->extract( $like_thing );
Applied on all objects where $object->does( $classname ) OR $object->isa( $classname );
this doesn't make complete sense, but its handy for lazy people.
-
HashRef[ [Extractor](https://metacpan.org/pod/Search::GIN::Extract::ClassMap::Types#Extractor) ]
-
HashRef
's are automatically type-cast.
Kent Fredric kentnl@cpan.org
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.