Myco::QueryTemplate - a Myco template class
A template class for Myco::Query and Myco::Entity::Meta::Query. Provides full encapsulation of Tangram Query object construction and manipulation.
Constructor, accessors, and other methods -- as inherited from Myco::Entity.
Attributes may be initially set during object construction (with new()) but otherwise are accessed solely through accessor methods. Typical usage:
new()
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.
eval
Get attribute value
$value = $obj->get_attribute;
A listing of available attributes follows:
type: string
Name of the query.
type: string required
Description of the query.
The remote class of objects to return.
type: perl_dump $query->set_filter( $filter );
The string dump of ::Filter and ::Clause objects comprising the filter.
type: flat_hash required $query->set_remote( {'$u_' => 'Myco::User'} );
A hash of remote variable and class names. Use declare_remote to add new ones.
type: perl_dump $query->set_params( last_name => ['$p_', 'last'], middle_name => ['$p_', 'middle', 1], first_initial => ['$p_', 'middle', widget => ['textfield', -size => 2, maxlength => 2], ], );
A hash of arrays of arg names consisting of the relevant remotes, and the attribute name. May also include boolean flag to indicate optionality, as well as a custom CGI widget spec.
$query->set_params_order( ['mid', 'log'] );
Since params is a hash, its values cannot be accessed in the order it was originally specified, this attribute can used to explicity set the order.
$query->add_remotes( { '$peeps_' => 'Myco::Person', '$stooges_' => 'Myco::Person::Stooge'} );
Add remotes without clobbering the current list.
my $filter_string = $query->get_filter_string;
A wrapper method around Myco::Query::Part::Filter->get_combined_parts. Works on the filter attribute. Accepts as an argument the same hash of parameters passed to run_query.
my @results = $query->run_query;
Run the query.
my $ui_md = $query->get_ui_md;
Returns ::UI metadata objects for each attribute in params attribute. Keyed by attribute alias
my $ref_params = $query->get_ref_params;
Returns a hash reference like { 'person' => 'Myco::Person' } for any 'ref' or 'iset' params required by the query object.
my $cgi_widget = $query->get_closure( 'first_name' );
Get an appropriate CGI widget for a given param. Leverages Myco::Entity::Meta::Attribute::UI.
To install Myco, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Myco
CPAN shell
perl -MCPAN -e shell install Myco
For more information on module installation, please visit the detailed CPAN module installation guide.