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(where_conditions, source, forced_index_name: nil) ⇒ KeyFieldsDetector

Returns a new instance of KeyFieldsDetector.



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

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

Instance Method Details

#hash_keyObject



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

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

#index_nameObject



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

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

#key_present?Boolean

Returns:

  • (Boolean)


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

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

#non_key_present?Boolean

Returns:

  • (Boolean)


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

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

#range_keyObject



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

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