NAME
Myco::Query::Part::Clause - a Myco entity class
SYNOPSIS
use Myco;
# Constructors. See Myco::Entity for more.
my $clause = Myco::Query::Part::Clause->new( remote => '$person_remote_',
attr => 'last_name',
oper => 'eq',
param => 'Hancock' );
my $stringified_clause = $clause->get_clause;
print "OK\n" if $stringified_clause eq
'$person_remote_->{last_name} eq Hancock';
# On second thought, I want anyone _not_ a 'Hancock'...
$clause->set_oper( 'ne' );
print "Better now\n" if $clause->get_clause =~ /ne Hancock$/;
DESCRIPTION
The clause is the basic building block of a Myco query. It encapsulates the perl-namespace remote object name (in the example above '$person_remote_', the object attribute name that our logic is operating on, the operator, and the paramater we're using. Full support for all types of parameters is offered, including scalars, objects, sets, etc. See Tangram for an exhaustive discussion of these, as well as how to design a query.
COMMON ENTITY INTERFACE
Constructor, accessors, and other methods -- as inherited from Myco::Entity.
ATTRIBUTES
Attributes may be initially set during object construction (with new()
) but otherwise are accessed solely through accessor methods. Typical usage:
Set attribute value
$obj->set_attribute($value);
Check functions (see Class::Tangram) perform data validation. If there is any concern that the set method might be called with invalid data then the call should be wrapped in an
eval
block to catch exceptions that would result.Get attribute value
$value = $obj->get_attribute;
A listing of available attributes follows:
remote
type: transient
$query_clause->set_remote( '$p_' );
The remote variable name
attr
type: transient
# Last name
$query_clause->set_attr( 'last' );
The persistent attribute name corresponding to the remote API.
oper
type: transient
$query_clause->set_oper( 'ne' );
The Perl operator to be appended to the clause.
param
type: transient
$query_clause->set_param( 'Hancock' );
The parameter value used in the query clause. Certain method operators are multipart in nature, such as 'match', which takes a left regex operator, the param itself, and a right regex operator. Either of these operators may be left undefined. This will be discovered wehn calling 'get_clause'.
ADDED CLASS / INSTANCE METHODS
get_clause
my $stringified_clause = $clause->get_clause;
Concatenates into a string clause the atomic parts of a Myco::Query::Part::Clause. Accepts as an argument a hash of parameters that are marked as optional in the Myco::Query 'params' attribute.
LICENSE AND COPYRIGHT
Copyright (c) 2006 the myco project. All rights reserved. This software is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Myco::Query::Part::Clause::Test, Myco::Entity, Myco, Tangram, Class::Tangram, myco-mkentity