Method: Dynamoid::Criteria::Chain#initialize

Defined in:
lib/dynamoid/criteria/chain.rb

#initialize(source) ⇒ Chain

Create a new criteria chain.

Parameters:

  • source (Class)

    the class upon which the ultimate query will be performed.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dynamoid/criteria/chain.rb', line 19

def initialize(source)
  @query = {}
  @source = source
  @consistent_read = false
  @scan_index_forward = true

  # Honor STI and :type field if it presents
  type = @source.inheritance_field
  if @source.attributes.key?(type)
    @query[:"#{type}.in"] = @source.deep_subclasses.map(&:name) << @source.name
  end

  # we should re-initialize keys detector every time we change query
  @key_fields_detector = KeyFieldsDetector.new(@query, @source)
end