module Mmtrix::Agent::HashExtensions

Public Instance Methods

stringify_keys_in_object(object) click to toggle source

recurses through hashes and arrays and stringifies keys

# File lib/mmtrix/agent/hash_extensions.rb, line 11
def stringify_keys_in_object(object)
  case object
  when Hash
    object.inject({}) do |memo, (k, v)|
      memo[k.to_s] = stringify_keys_in_object(v)
      memo
    end
  when Array
    object.map {|o| stringify_keys_in_object(o)}
  else
    object
  end
end