lib/activesearch/mongoid.rb in activesearch-0.1.3 vs lib/activesearch/mongoid.rb in activesearch-0.2.0

- old
+ new

@@ -1,31 +1,31 @@ require 'activesearch/base' require 'activesearch/proxy' require 'activesearch/mongoid/model' module ActiveSearch - - def self.search(text, conditions = {}) - Proxy.new(text, conditions) do |text, conditions| + + def self.search(text, conditions = {}, options = {}) + Proxy.new(text, conditions, options) do |text, conditions| text = text.downcase.split(/\s+/) conditions.keys.each { |k| conditions["_stored.#{k}"] = conditions.delete(k) } conditions.merge!(:_keywords.in => text + text.map { |word| "#{I18n.locale}:#{word}"}) Mongoid::Model.where(conditions) end end - + module Mongoid def self.included(base) base.class_eval do include Base end end - + protected def reindex ActiveSearch::Mongoid::Model.reindex(self, self.search_fields, self.search_options) end - + def deindex ActiveSearch::Mongoid::Model.deindex(self) end end end \ No newline at end of file