Class: Dynamoid::Criteria::KeyFieldsDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamoid/criteria/key_fields_detector.rb

Defined Under Namespace

Classes: Query

Instance Method Summary collapse

Constructor Details

#initialize(query, source, forced_index_name: nil) ⇒ KeyFieldsDetector

Returns a new instance of KeyFieldsDetector.


27
28
29
30
31
32
33
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 27

def initialize(query, source, forced_index_name: nil)
  @query = query
  @source = source
  @query = Query.new(query)
  @forced_index_name = forced_index_name
  @result = find_keys_in_query
end

Instance Method Details

#hash_keyObject


43
44
45
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 43

def hash_key
  @result && @result[:hash_key]
end

#index_nameObject


51
52
53
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 51

def index_name
  @result && @result[:index_name]
end

#key_present?Boolean

Returns:

  • (Boolean)

39
40
41
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 39

def key_present?
  @result.present? && @query.contain_with_eq_operator?(hash_key)
end

#non_key_present?Boolean

Returns:

  • (Boolean)

35
36
37
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 35

def non_key_present?
  !@query.contain_only?([hash_key, range_key].compact)
end

#range_keyObject


47
48
49
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 47

def range_key
  @result && @result[:range_key]
end