Delegate Extraction based on class
Perl
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/Search/GIN/Extract
maint
misc
t
.gitignore
.mailmap
.perltidyrc
.travis.yml
CONTRIBUTING.pod
Changes
INSTALL.SKIP
LICENSE
MANIFEST.SKIP
Makefile.PL
README.mkdn
dist.ini
dist.ini.meta
perlcritic.rc
weaver.ini

README.mkdn

NAME

Search::GIN::Extract::ClassMap - Delegate Extraction based on class.

VERSION

version 1.000004

SYNOPSIS

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.

WARNING

This is an early release, API is prone to change without much warning, but best attempts will be made to avoid the need.

DESCRIPTION

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.

METHODS

extract_values

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.

ATTRIBUTES

extract_isa

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 );

$isa_thing

  • HashRef[ [Extractor](https://metacpan.org/pod/Search::GIN::Extract::ClassMap::Types#Extractor) ]

  • CoercedClassMap

  • ::ClassMap::Isa

    HashRef's are automatically type-cast.

extract_does

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 );

$does_thing

  • HashRef[ [Extractor](https://metacpan.org/pod/Search::GIN::Extract::ClassMap::Types#Extractor) ]

  • CoercedClassMap

  • ::ClassMap::Does

    HashRef's are automatically type-cast.

extract

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.

$like_thing

  • HashRef[ [Extractor](https://metacpan.org/pod/Search::GIN::Extract::ClassMap::Types#Extractor) ]

  • CoercedClassMap

  • ::ClassMap::Like

    HashRef's are automatically type-cast.

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.