Class: Hash

Inherits:
Object show all
Defined in:
lib/partigirb/core_ext.rb,
lib/partigirb/core_ext.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#stringify_keysObject

Return a new hash with all keys converted to strings.



5
6
7
8
9
10
# File 'lib/partigirb/core_ext.rb', line 5

def stringify_keys
  inject({}) do |options, (key, value)|
    options[key.to_s] = value
    options
  end
end

#stringify_keys!Object

Destructively convert all keys to strings.



13
14
15
16
17
18
# File 'lib/partigirb/core_ext.rb', line 13

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