Class: Hash

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) stringify_keys

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

- (Object) stringify_keys!



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