Class: Representable::Hash::Conversion

Inherits:
Object
  • Object
show all
Defined in:
lib/representable/hash/allow_symbols.rb

Class Method Summary collapse

Class Method Details

.stringify_keys(hash) ⇒ Object

DISCUSS: we could think about mixin in IndifferentAccess here (either hashie or ActiveSupport). or decorating the hash.


17
18
19
20
21
22
23
24
# File 'lib/representable/hash/allow_symbols.rb', line 17

def self.stringify_keys(hash)
  hash = hash.dup

  hash.keys.each do |k|
    hash[k.to_s] = hash.delete(k)
  end
  hash
end