stringify snippets

Stringify a Ruby Hash

Tagged stringify, hash, ruby, tokyo-cabinet  Languages ruby
class Hash
  def stringify
    inject({}) do |options, (key, value)|
      options[key.to_s] = value.to_s
      options
    end
  end

  def stringify!
    each do |key, value|
      delete(key)
      store(key.to_s, value.to_s)
    end
  end
end