Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/extlib_lite/core_extensions/hash.rb

Instance Method Summary collapse

Instance Method Details

#stringifyObject

Convert all keys to strings and deeply converts all values to strings Useful for creating a query string

Examples:

{
  :number => 1
  :time => {
    :actual_time => 2010-10-09 11:49:59 UTC
  }
}.stringify #=>
{
  "number" => "1",
  "time" => {
    "actual_time" => "2010-10-09 11:49:59 UTC"
  }
}


20
21
22
23
24
25
26
27
28
# File 'lib/extlib_lite/core_extensions/hash.rb', line 20

def stringify
  stringified_hash = {}
  each do |key, value|
    value.is_a?(Hash) ?
      stringified_hash[key.to_s] = value.stringify :
      stringified_hash[key.to_s] = value.to_s
  end
  stringified_hash
end