Class: Dynamoid::Criteria::KeyFieldsDetector
- Inherits:
-
Object
- Object
- Dynamoid::Criteria::KeyFieldsDetector
- Defined in:
- lib/dynamoid/criteria/key_fields_detector.rb
Defined Under Namespace
Classes: Query
Instance Method Summary collapse
- #hash_key ⇒ Object
- #index_name ⇒ Object
-
#initialize(where_conditions, source, forced_index_name: nil) ⇒ KeyFieldsDetector
constructor
A new instance of KeyFieldsDetector.
- #key_present? ⇒ Boolean
- #non_key_present? ⇒ Boolean
- #range_key ⇒ Object
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_key ⇒ Object
42 43 44 |
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 42 def hash_key @result && @result[:hash_key] end |
#index_name ⇒ Object
50 51 52 |
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 50 def index_name @result && @result[:index_name] end |
#key_present? ⇒ 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
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_key ⇒ Object
46 47 48 |
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 46 def range_key @result && @result[:range_key] end |