Name

Object::Relation::Search - Manage Object::Relation search parameters

Synopsis

use Object::Relation::Search;
my $search = Object::Relation::Search->new(
    param    => $param,
    operator => $operator,
    negated  => $negated,
    data     => $data,
    class    => $class,
);
# later
$search->param($new_param);
my $method = $search->search_method;
$store->$method($search);

Description

This class manages all of the data necessary for creation of individual search parameters ("name = 'foo'", "age >= 21", etc.). When enough slots are filled, search_method() will return the name of the method that will generate the appropriate search token.

Constructors

new

my $search = Object::Relation::Search->new( class => $class );
# or
my $search = Object::Relation::Search->new(
    param    => $param,
    operator => $operator,
    negated  => $negated,
    data     => $data,
    class    => $class,
);

Creates and returns a new search manager.

If passed named parameters, those respective slots will be populated with the values.

Each of the parameters can also be accessed via a getter/setter. See the docs for the corresponding parameter to understand its function.

search_method

my $method = $search->search_method;

This method uses the attributes that have been set to determine which search method the store Object::Relation::Handle class should dispatch to.

Instance Methods

param

my $param = $search->param;
$search->param($param);

Getter/Setter for the parameter specified for the search. Most often this will correspond to the name of an attribute in the class described by the class object returned by class(), but it might instead refer to an object in another class by using the dot notation, e.g., "class.attr". See Object::Relation::Handle for details on the possible parameters.

data

$search->data([$data]);

Getter/Setter for the data you wish to search for.

formatted_data

my $data = $search->formatted_data;

This may go away in the future.

Returns data formatted by Data::Dumper. Individual values will be returned unquoted. ANY or BETWEEN searches will be returned as a string wrapped in parentheses with string values quoted.

negated

$search->negated(['NOT']);

Getter/Setter for the boolean attribute that determines whether or not the current search logic is negated.

operator

$search->operator([$operator]);t

Getter/Setter identifying which operator is actually being used for the current search. Examples are '<=', '=', 'LIKE', etc.

The orginal_operator method will return the operator used in the search request. This method returns the operator that will be used in the actual request, if different. For example, if negated returns true and original_operator returns EQ, operator will return !=.

original_operator

$search->original_operator([$operator]);t

Getter/Setter identifying which operator was being used for the current search. Examples are 'LE', 'EQ', 'LIKE', etc.

class

$search->class([$class]);

Getter/Setter for the class which contains the Object::Relation::Meta::Class object for the class being searched.

key

my $key = $search->key;

Returns the class key for the Object::Relation object this search object refers to. This is a convenient (cached) shortcut for:

$search->class->key;

notes

my $notes = $search->notes;
my $val = $search->notes($key);
$search->notes($key => $val);

Manages a hash of arbitrary notes to be associated with the search object. These may be populated with values by the store class to help it collect the data necessary to perform a search of the data store.

Copyright and License

Copyright (c) 2004-2006 Kineticode, Inc. <info@obj_relode.com>

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.