Class: Dynamoid::Criteria::KeyFieldsDetector::Query

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

Instance Method Summary collapse

Constructor Details

#initialize(where_conditions) ⇒ Query

Returns a new instance of Query.



8
9
10
11
12
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 8

def initialize(where_conditions)
  @where_conditions = where_conditions
  @fields_with_operator = where_conditions.keys.map(&:to_s)
  @fields = where_conditions.keys.map(&:to_s).map { |s| s.split('.').first }
end

Instance Method Details

#contain?(field_name) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 18

def contain?(field_name)
  @fields.include?(field_name.to_s)
end

#contain_only?(field_names) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 14

def contain_only?(field_names)
  (@fields - field_names.map(&:to_s)).blank?
end

#contain_with_eq_operator?(field_name) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/dynamoid/criteria/key_fields_detector.rb', line 22

def contain_with_eq_operator?(field_name)
  @fields_with_operator.include?(field_name.to_s)
end