Data::SearchEngine::Item - An individual search result.


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

Index


Code Index:

NAME

Top

Data::SearchEngine::Item - An individual search result.

SYNOPSIS

Top

  $result->add(Data::SearchEngine::Item->new(
    id => 'SKU',
    values => {
        name => 'Foobar',
        description => 'A great foobar!'
    },
    score => 1.0
  ));

DESCRIPTION

Top

An item represents an individual search result. It's really just a glorified HashRef.

ATTRIBUTES

Top

id

A unique identifier for this item.

values

The name value pairs for this item.

score

The score this item earned.

METHODS

Top

keys

Returns the keys from the values HashRef, e.g. a list of the value names for this item.

get_value

Returns the value for the specified key for this item.

set_value

Sets the value for the specified key for this item.

AUTHOR

Top

Cory G Watson, <gphat at cpan.org>

COPYRIGHT & LICENSE

Top


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

package Data::SearchEngine::Item;
use Moose;
use MooseX::Storage;

with 'MooseX::Storage::Deferred';

has id => (
    is => 'rw',
    isa => 'Str'
);

has score => (
    is => 'rw',
    isa => 'Num',
    default => 0
);

has values => (
    traits  => [ 'Hash' ],
    is      => 'rw',
    isa     => 'HashRef[Str|ArrayRef[Str]|Undef]',
    default => sub { {} },
    handles => {
        keys        => 'keys',
        get_value   => 'get',
        set_value   => 'set',
    },
);

__PACKAGE__->meta->make_immutable;

1;