Class: Hash

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

Instance Method Summary collapse

Instance Method Details

#stringify_keysObject

Return a new hash with all keys converted to strings.


6
7
8
# File 'lib/ext/hash.rb', line 6

def stringify_keys
  dup.stringify_keys!
end

#stringify_keys!Object


10
11
12
13
14
15
# File 'lib/ext/hash.rb', line 10

def stringify_keys!
  keys.each do |key|
    self[key.to_s] = delete(key)
  end
  self
end