lib/activesearch/mongoid.rb in activesearch-0.3.1 vs lib/activesearch/mongoid.rb in activesearch-0.3.2

- old
+ new

@@ -1,18 +1,32 @@ require 'activesearch/base' +require 'activesearch/results_set' require 'activesearch/proxy' + +require 'activesearch/mongoid/results_set' require 'activesearch/mongoid/full_text_search_query' require 'activesearch/mongoid/index' module ActiveSearch def self.search(text, conditions = {}, options = {}) + conditions.symbolize_keys! + options.symbolize_keys! + + clean_locale(conditions, options) + + results_set = ActiveSearch::Mongoid::Index.search(text, conditions, options) + + Proxy.new(results_set, text, options) + end + + protected + + def self.clean_locale(conditions, options) locale = options[:locale] || I18n.locale conditions[:locale] ||= locale - Proxy.new(text, conditions, options) do |text, conditions| - ActiveSearch::Mongoid::Index.search(text, conditions, options) - end + conditions.delete(:locale) if options[:locale] == false end module Mongoid def self.included(base) base.class_eval do \ No newline at end of file