Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/core_ext/hash.rb
Overview
stolen^H^H^H^H^H^Hborrowed from Rails’ ActiveSupport
Instance Method Summary collapse
-
#symbolize_keys ⇒ Object
Return a new hash with all keys converted to symbols, as long as they respond to
to_sym. -
#symbolize_keys! ⇒ Object
Destructively convert all keys to symbols, as long as they respond to
to_sym.
Instance Method Details
#symbolize_keys ⇒ Object
Return a new hash with all keys converted to symbols, as long as they respond to to_sym.
5 6 7 |
# File 'lib/core_ext/hash.rb', line 5 def symbolize_keys dup.symbolize_keys! end |
#symbolize_keys! ⇒ Object
Destructively convert all keys to symbols, as long as they respond to to_sym.
11 12 13 14 15 16 |
# File 'lib/core_ext/hash.rb', line 11 def symbolize_keys! keys.each do |key| self[(key.to_sym rescue key) || key] = delete(key) end self end |