Class: Dynomite::Item::Query::Params::Function::SizeFn
- Includes:
- Relation::ComparisionMap
- Defined in:
- lib/dynomite/item/query/params/function/size_fn.rb
Constant Summary
Constants included from Relation::ComparisionMap
Relation::ComparisionMap::COMPARISION_MAP
Constants included from Types
Instance Method Summary collapse
- #attribute_names ⇒ Object
- #attribute_values ⇒ Object
-
#filter_expression ⇒ Object
Product.size_fn(“category.gt”, 100).
Methods included from Relation::ComparisionMap
#comparision_for, #comparision_operators
Methods inherited from Base
#build_attribute_names_with_dot_paths, #initialize
Methods included from Types
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
Constructor Details
This class inherits a constructor from Dynomite::Item::Query::Params::Function::Base
Instance Method Details
#attribute_names ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/dynomite/item/query/params/function/size_fn.rb', line 20 def attribute_names paths = @query[:size_fn].map do |size_fn| path = size_fn[:path] path.split('.')[0..-2].join('.') # remove last element: comparision operator end build_attribute_names_with_dot_paths(paths) end |
#attribute_values ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/dynomite/item/query/params/function/size_fn.rb', line 28 def attribute_values values = {} @query[:size_fn].each_with_index do |size_fn, index| size = size_fn[:size] values[":size_value#{index}"] = size end values end |
#filter_expression ⇒ Object
Product.size_fn(“category.gt”, 100)
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dynomite/item/query/params/function/size_fn.rb', line 6 def filter_expression filter_expression = [] @query[:size_fn].each_with_index do |size_fn, index| path, size = size_fn[:path], size_fn[:size] elements = path.split('.') operator = elements.pop # remove last element path = elements.join('.') # path no longer has operator comparision = comparision_for(operator) path = normalize_expression_path(path) filter_expression << "size(#{path}) #{comparision} :size_value#{index}" end filter_expression end |