Module: CatchNotes::Util::ClassMethods
- Defined in:
- lib/catch_notes.rb
Instance Method Summary collapse
-
#stringify_keys(input_hash) ⇒ Object
Takes a hash and returns a new hash with all keys transformed into strings.
Instance Method Details
#stringify_keys(input_hash) ⇒ Object
Takes a hash and returns a new hash with all keys transformed into strings.
Parameters
-
input_hash- The hash to stringify
Example
stringify_keys( :hello => "world", 1 => 2) # => {'hello' => 'world', '1' => 2}
13 14 15 16 17 18 |
# File 'lib/catch_notes.rb', line 13 def stringify_keys (input_hash) input_hash.map{|k,v| [k.to_s, v]}.inject({}) do |hash, pair| hash[pair.first] = pair.last hash end end |