Class: Dynomite::Item::Query::Params::Function::BeginsWith

Inherits:
Base
  • Object
show all
Defined in:
lib/dynomite/item/query/params/function/begins_with.rb

Direct Known Subclasses

Contains

Constant Summary

Constants included from Types

Types::TYPE_MAP

Instance Method Summary collapse

Methods inherited from Base

#build_attribute_names_with_dot_paths, #initialize

Methods included from Types

#type_map

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_namesObject



13
14
15
16
# File 'lib/dynomite/item/query/params/function/begins_with.rb', line 13

def attribute_names
  paths = @query[query_key].map { |begins_with| begins_with[:path] }
  build_attribute_names_with_dot_paths(paths)
end

#attribute_valuesObject



18
19
20
21
22
23
24
25
# File 'lib/dynomite/item/query/params/function/begins_with.rb', line 18

def attribute_values
  values = {}
  @query[query_key].each do |begins_with|
    path, substr = begins_with[:path], begins_with[:substr]
    values[":#{substr}"] = substr
  end
  values
end

#filter_expressionObject



3
4
5
6
7
8
9
10
11
# File 'lib/dynomite/item/query/params/function/begins_with.rb', line 3

def filter_expression
  filter_expression = []
  @query[query_key].each do |begins_with|
    path, substr = begins_with[:path], begins_with[:substr]
    path = normalize_expression_path(path)
    filter_expression << "#{query_key}(#{path}, :#{substr})"
  end
  filter_expression
end

#query_keyObject

interface method so Contains < BeginsWith can override



28
29
30
# File 'lib/dynomite/item/query/params/function/begins_with.rb', line 28

def query_key
  :begins_with # must be a symbol
end