MooseX::Role::Searchable - Add search convenience methods to a class.
version 0.01
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);
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.
pack
Returns a hashref with values for all of the search field names that were specified on the various attributes with the Searchable trait.
Cory G Watson <gphat@cpan.org>
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.
To install MooseX::Meta::Attribute::Searchable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Meta::Attribute::Searchable
CPAN shell
perl -MCPAN -e shell install MooseX::Meta::Attribute::Searchable
For more information on module installation, please visit the detailed CPAN module installation guide.