Class: Atomsphere::Query::Builder
- Inherits:
-
Object
- Object
- Atomsphere::Query::Builder
- Defined in:
- lib/atomsphere/query/builder.rb,
lib/atomsphere/query/builder/group.rb,
lib/atomsphere/query/builder/property.rb
Overview
DSL for onstructing an Atomsphere::Query
Defined Under Namespace
Instance Attribute Summary collapse
-
#query ⇒ Atomsphere::Query
readonly
output query object.
Instance Method Summary collapse
-
#group(operator, &block) ⇒ Object
Define a GroupingExpression at the top level of the query.
-
#initialize(object_type) ⇒ Builder
constructor
A new instance of Builder.
-
#method_missing(m, *args, &block) ⇒ Object
Allows for defining of SimpleExpressions at the top level of the query.
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
Allows for defining of SimpleExpressions at the top level of the query. Creates a top level GroupingExpression if none yet exists to contain it.
31 32 33 34 35 36 |
# File 'lib/atomsphere/query/builder.rb', line 31 def method_missing m, *args, &block @query.filter = GroupingExpression.new(:and) unless @query.filter Group.new(@query.filter).instance_eval do send(m, *args, &block) end end |
Instance Attribute Details
#query ⇒ Atomsphere::Query (readonly)
output query object
7 8 9 |
# File 'lib/atomsphere/query/builder.rb', line 7 def query @query end |
Instance Method Details
#group(operator, &block) ⇒ Object
Define a GroupingExpression at the top level of the query. If called more than once, subsequent calls create a grouping expression within the first created GroupingExpression.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/atomsphere/query/builder.rb', line 17 def group operator, &block new_group = GroupingExpression.new(operator) Group.new(new_group).instance_eval(&block) if @query.filter @query.filter.nested_expression << new_group else @query.filter = new_group end end |