Salvation::MacroProcessor::Hooks - Base class for your hooks with implementation of actual logic for Salvation::MacroProcessor::Spec
Salvation::MacroProcessor::Hooks-derived classes are a place for your implementation of actual query execution logic. As Salvation::MacroProcessor::Spec aggregates query parts in a complete query for you, you should then do something with aggregated query by yourself.
For the system to work properly, your hook class should have specific name made using following pattern:
sprintf( 'Salvation::MacroProcessor::Hooks::%s', $your_class_name )
, where $your_class_name is the name of a class you want to have Salvation::MacroProcessor support.
Your hook will be loaded automatically when it need to be loaded.
If there is no hook for current class, but there is hook for one of parent classes - this hook will be used, so you can define one parent class with Salvation::MacroProcessor support and just inherit this class by other classes so each child won't need to have its own hook.
You can redefine following methods to achieve your own goals.
$hook -> check( $spec, $object );
Checks if given $object could be selected using this $spec.
$spec is a Salvation::MacroProcessor::Spec instance.
$object is an object representing a single row of data returned by the query.
Boolean value should be returned, false means "skip this object" and true means "yes, this object is what we want".
$hook -> query_from_attribute( $method_description, $attr, @rest );
Generates query part which needs to be applied to the query to get an object which satisfies specified criteria.
This method will be called if all following conditions are true:
$method_description is a Salvation::MacroProcessor::MethodDescription instance.
$attr is a Moose::Meta::Attribute instance.
@rest is a list of arguments of the same types, conditions and meaning as it is for query argument of Salvation::MacroProcessor::smp_add_description when $query is a CodeRef.
Return value should also be as the one of $query function of Salvation::MacroProcessor::smp_add_description.
$hook -> select( $spec, $additional_query, $additional_args );
Selects objects using given $spec with a mix of $additional_query and $additional_args.
$additional_query and $additional_args are both passed in by you or any other developer who will try to make a query. Though both are thought of as ArrayRef's.
$additional_query's meaning is "some custom query part we need to apply to the query".
$additional_args's meaning is "some additional custom arguments we need to pass to the method which will then perform a request to complete the query".
Return value will be returned directly to caller which is your custom code issued Salvation::MacroProcessor::Spec::select. Though return value is thought of as Salvation::MacroProcessor::Iterator instance.
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.