Module: SearchCop::Helpers

Defined in:
lib/search_cop/helpers.rb

Class Method Summary collapse

Class Method Details

.sanitize_default_operator(query_options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/search_cop/helpers.rb', line 3

def self.sanitize_default_operator(query_options)
  return "and" unless query_options.key?(:default_operator)

  default_operator = query_options[:default_operator].to_s.downcase

  unless ["and", "or"].include?(default_operator)
    raise(SearchCop::UnknownDefaultOperator, "Unknown default operator value #{default_operator}")
  end

  default_operator
end