Module: SearchCop::Helpers

Defined in:
lib/search_cop.rb

Class Method Summary collapse

Class Method Details

.sanitize_default_operator(hash, delete_hash_option = false) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/search_cop.rb', line 74

def self.sanitize_default_operator(hash, delete_hash_option=false)
  default_operator = :and
  if hash.member?(:default_operator)
    unless [:and, :or].include?(hash[:default_operator])
      raise(SearchCop::UnknownDefaultOperator, "Unknown default operator value #{hash[:default_operator]}")
    end

    default_operator = hash[:default_operator]
  end

  hash.delete(:default_operator) if delete_hash_option

  default_operator
end