Module: Autosuggest::Mongoid

Defined in:
lib/autosuggest/helpers.rb

Class Method Summary collapse

Class Method Details

.query(options) ⇒ Object



9
10
11
# File 'lib/autosuggest/helpers.rb', line 9

def self.query(options)
  options[:object].where(options[:name].to_sym => /.*#{options[:query]}.*/i).limit(options[:limit]).order_by(resolve_order_syntax(options[:order]))
end

.resolve_order_syntax(order) ⇒ Object



13
14
15
16
# File 'lib/autosuggest/helpers.rb', line 13

def self.resolve_order_syntax(order)
  fields = order.split
  [fields[0], fields[1].downcase.to_sym]
end