module Metova::Responders::SearchResponder
Public Class Methods
new(*)
click to toggle source
Calls superclass method
# File lib/metova/responders/search_responder.rb, line 5 def initialize(*) super @resource = search(@resource, query) if searching? end
Private Instance Methods
exclusive?()
click to toggle source
# File lib/metova/responders/search_responder.rb, line 31 def exclusive? if controller.params[:search][:_operator] =~ /OR/i false else true end end
fuzzy?()
click to toggle source
# File lib/metova/responders/search_responder.rb, line 27 def fuzzy? controller.params[:search][:_fuzzy] == '1' end
query()
click to toggle source
# File lib/metova/responders/search_responder.rb, line 23 def query controller.params[:search][:query] end
search(resource, query = {})
click to toggle source
# File lib/metova/responders/search_responder.rb, line 11 def search(resource, query = {}) if fuzzy? resource.fuzzy_search query, exclusive? else resource.basic_search query, exclusive? end end
searching?()
click to toggle source
# File lib/metova/responders/search_responder.rb, line 19 def searching? controller.params.include?(:search) && controller.params[:search].is_a?(Hash) end