Class: Dynomite::Item::Query::Params::Filter
- Inherits:
-
Base
- Object
- Base
- Dynomite::Item::Query::Params::Filter
show all
- Defined in:
- lib/dynomite/item/query/params/filter.rb
Constant Summary
Constants included
from Types
Types::TYPE_MAP
Instance Method Summary
collapse
Methods inherited from Base
#expression_string, #function_names, #join_expressions
Methods included from Helpers
#all_where_field_names, #all_where_fields, #disable_index_for_any_or?, #disable_index_for_consistent_read?, #disable_index_for_not?, #normalize_expression_path, #normalize_project_expression, #query, #scan_required?, #with_where_groups
Methods included from Types
#type_map
Constructor Details
#initialize(relation, index) ⇒ Filter
Returns a new instance of Filter.
3
4
5
6
|
# File 'lib/dynomite/item/query/params/filter.rb', line 3
def initialize(relation, index)
@relation, @index = relation, index
@expressions = []
end
|
Instance Method Details
#build ⇒ Object
8
9
10
11
|
# File 'lib/dynomite/item/query/params/filter.rb', line 8
def build
build_where
build_functions
end
|
#build_functions ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/dynomite/item/query/params/filter.rb', line 29
def build_functions
function_names.each do |function_name|
function = Function.const_get(function_name.camelize).new(@relation.query)
filter_expression = function.filter_expression
@expressions += filter_expression
end
end
|
#build_where ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/dynomite/item/query/params/filter.rb', line 19
def build_where
with_where_groups do |where_group|
expression = where_group.build_compare_expression_if do |field|
@index.nil? || !@index.fields.include?(field)
end
@expressions << expression if expression
end
end
|
#expression ⇒ Object
14
15
16
17
|
# File 'lib/dynomite/item/query/params/filter.rb', line 14
def expression
build
join_expressions
end
|