Data::SearchEngine::Meta::Attribute::Trait::Digestable - Digest flag & configuration


Data-SearchEngine documentation Contained in the Data-SearchEngine distribution.

Index


Code Index:

NAME

Top

Data::SearchEngine::Meta::Attribute::Trait::Digestable - Digest flag & configuration

SYNOPSIS

Top

If a Data::SearchEngine::Query attribute has this meta-attribute, then it will be added to the digest that identifies the uniqueness of a Query.

If the attribute is a scalar, you do not need to specify a digest_value. The scalar value can just be added to the digest.

For example, if your Query subclass allows the choice of a particular category to search within, you would obviously want queries with different categories (or lack thereof) to have different digests.

    has 'category' => (
        traits      => [qw(Digestable)],
        is          => 'rw',
        isa         => 'MyApp::Category',
        digest_value=> sub { $self->category->name }
    );

When computing it's digest, your query will now add the value of the category to the computation, thereby guaranteeing uniqueness!

ATTRIBUTES

Top

digest_value

A coderef that will return a string identifying the value of this attribute for adding to the Query's digst.

AUTHOR

Top

Cory G Watson, <gphat at cpan.org>

COPYRIGHT & LICENSE

Top


Data-SearchEngine documentation Contained in the Data-SearchEngine distribution.

package Data::SearchEngine::Meta::Attribute::Trait::Digestable;
use Moose::Role;

has digest_value => (
    is => 'ro',
    isa => 'CodeRef',
    predicate => 'has_digest_value'
);

1;

__END__