Module: Elastic::AppSearch::Utils

Extended by:
Utils
Included in:
Utils
Defined in:
lib/elastic/app-search/utils.rb

Instance Method Summary collapse

Instance Method Details

#stringify_keys(hash) ⇒ Object



6
7
8
9
10
# File 'lib/elastic/app-search/utils.rb', line 6

def stringify_keys(hash)
  hash.each_with_object({}) do |(key, value), out|
    out[key.to_s] = value
  end
end

#symbolize_keys(hash) ⇒ Object



12
13
14
15
16
17
# File 'lib/elastic/app-search/utils.rb', line 12

def symbolize_keys(hash)
  hash.each_with_object({}) do |(key, value), out|
    new_key = key.respond_to?(:to_sym) ? key.to_sym : key
    out[new_key] = value
  end
end