Object::Relation::Parser - The Object::Relation parser for search requests
use Object::Relation::Parser qw/parse/; use Object::Relation::Lexer::Code qw/lexer_stream/; sub _create_ir { my ($self, $search_request) = @_; my $stream = lexer_stream($search_request); my $intermediate_representation = parse($stream, $store); return $intermediate_representation; }
This class takes the tokens produced by a Object::Relation lexer and creates an intermediate representation that can be easily converted to a search request for a given store.
my $ir = parse($stream, $store);
This function takes a lexer stream produced by a Object::Relation lexer and the store object to be searched. It returns an intermediate representation suitable for converting into a data store search (such as a SQL WHERE clause).
WHERE
This function returns an array reference of Object::Relation::Search objects and groups of these Search objects. Groups may be simple groups, "AND" groups or "OR" groups.
Simple groups are merely a reference to an array of search objects:
[ $search1, $search2, $search3, ]
All searches in a simple group must succeed for the search to succeed.
"AND" groups are array references with the string "AND" as the first element.
[ [ 'AND', $search2, $search3, ] ]
An "OR" group is the string "OR" followed by an array reference.
[ 'OR', [ $search1, $search2, ] ]
And of the above groups may be nested.
AND( name => 'foo', l_name => 'something', ), OR( age => GT 3 ), OR( one__type => LIKE 'email', fav_number => GE 42 )
The above search, whether it is a code search or a string search, should produce the same IR:
[ [ 'AND', $name_search, $lname_search, ], 'OR', [ $age_search, ], 'OR', [ $one_type_search, $fav_number_search, ] ]
Throws:
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.
To install Object::Relation, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Object::Relation
CPAN shell
perl -MCPAN -e shell install Object::Relation
For more information on module installation, please visit the detailed CPAN module installation guide.