Method: Brief::DocumentMapper::Query#where

Defined in:
lib/brief/document_mapper.rb

#where(constraints_hash) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/brief/document_mapper.rb', line 38

def where(constraints_hash)
  selector_hash = constraints_hash.reject { |key, _value| !key.is_a? Selector }
  symbol_hash = constraints_hash.reject { |key, _value| key.is_a? Selector }
  symbol_hash.each do |attribute, value|
    selector = Selector.new(attribute: attribute, operator: 'equal')
    selector_hash.update(selector => value)
  end
  @where.merge! selector_hash
  self
end