module Scalastic::Normalizer
Public Instance Methods
normalized(hash)
click to toggle source
# File lib/scalastic/normalizer.rb, line 5 def normalized(hash) return hash if hash.keys.first.is_a?(String) normalize_internal(hash) end
safe_get(hash, *keys)
click to toggle source
# File lib/scalastic/normalizer.rb, line 10 def safe_get(hash, *keys) keys.reduce(hash) do |h, k| h && (h[k.to_s] || h[k.to_sym]) end end
Private Instance Methods
normalize_internal(object)
click to toggle source
# File lib/scalastic/normalizer.rb, line 18 def normalize_internal(object) if (object.is_a?(Hash)) Hash[object.map{|k, v| [k.to_s, normalize_internal(v)]}] elsif object.respond_to?(:map) object.map{|i| normalize_internal(i)} else object end end