NAME
MooseX::Role::Searchable - Add search convenience methods to a class.
VERSION
version 0.01
SYNOPSIS
package MyObject;
use Moose;
with 'MooseX::Role::Searchable';
has 'name' => (
is => 'rw',
isa => 'Str',
traits => [ qw(MooseX::Meta::Attribute::Searchable) ],
search_field_names => [ qw(name name_ngram) ],
);
1;
# Later...
my $obj = MyObject->new(name => 'user');
my $href = $obj->get_searchable_hashref;
$searchengine->index(id => $obj->id, $href);
DESCRIPTION
When used in conjuntion with MooseX::Meta::Attribute::Searchable, this role can create HashRefs containing all the data necessary to index an object in a search index.
NOTE: This role expects that it's consuming class will have a pack
method that will return a HashRef, like the one provided by MooseX::Storage.
METHODS
get_searchable_hashref
Returns a hashref with values for all of the search field names that were specified on the various attributes with the Searchable trait.
AUTHOR
Cory G Watson <gphat@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Cold Hard Code, LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.