Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/scalr/core_extensions/hash.rb
Instance Method Summary collapse
Instance Method Details
#downcase_keys ⇒ Object
3 4 5 6 7 8 |
# File 'lib/scalr/core_extensions/hash.rb', line 3 def downcase_keys inject({}) do |, (key, value)| [(key.downcase.to_sym rescue key) || key] = value end end |
#downcase_keys! ⇒ Object
10 11 12 |
# File 'lib/scalr/core_extensions/hash.rb', line 10 def downcase_keys! self.replace(self.downcase_keys) end |
#recursive_downcase_keys! ⇒ Object
14 15 16 17 18 19 |
# File 'lib/scalr/core_extensions/hash.rb', line 14 def recursive_downcase_keys! downcase_keys! values.each{|h| h.recursive_downcase_keys! if h.is_a?(Hash) } values.select{|v| v.is_a?(Array) }.flatten.each{|h| h.recursive_downcase_keys! if h.is_a?(Hash) } self end |