Salvation::MacroProcessor::Spec - Query object
Salvation::MacroProcessor::Spec -> parse_and_new( $class_or_object, $query );
Creates and returns new query object, an instance of Salvation::MacroProcessor::Spec class.
$class_or_object is a class name or instance of the class which will be the base class for the query. It has been thought of as "I will check or select objects of that type".
$query is an object of type ArrayRef[ArrayRef[Any]]. It is the query you want to perform. Each inner ArrayRef represents a filter, a field which consists of two parameters: the first is the name and the second is the value. Imagine you have following $query object:
[ method => $value ]
. method here is the name of the method description which will be the part of the query, and $value is the value for this column, a condition for a filter. It should be thought of as "I want to select an object which method()' call returns the $value".
I.e., a query with two fields will look somewhat like this:
[ method1 => $value1 ],
[ method2 => $value2 ]
. Note this very explicit separation of fields.
$spec -> select();
$spec -> check( $object );
Checks if given $object could be selected using this $spec.
$object is an object representing a single row of data returned by the query.
Salvation::MacroProcessor::Spec -> new(
class => $class,
fields => $fields
Returns Salvation::MacroProcessor::Spec instance.
All arguments are required.
String (could be coerced from Object though), the name of base class for this query.
ArrayRef[Salvation::MacroProcessor::Field], list of fields used in this query.
$spec -> add_field( $field )
Add field to the list.
$field is a Salvation::MacroProcessor::Field instance.
$spec -> all_fields()
Returns an array of all fields (each is a Salvation::MacroProcessor::Field instance) used in the query.
$spec -> fields()
Returns an ArrayRef of all fields (each is a Salvation::MacroProcessor::Field instance) used in the query.
$spec -> query()
Processes fields, aggregates query parts and returns an ArrayRef which contains the final query.
All aggregations and processing here are done only once per object instance, so the second call to query of the same object instance will be much faster than first.
To install Salvation::MacroProcessor, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.