Class: Hash

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

Overview

We don’t necessarily have ActiveSupport loaded yet!

Instance Method Summary collapse

Instance Method Details

#symbolize_keysObject

Return a new hash with all keys converted to symbols.



55
56
57
58
59
60
# File 'lib/annotatable.rb', line 55

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

#symbolize_keys!Object

Destructively convert all keys to symbols.



63
64
65
# File 'lib/annotatable.rb', line 63

def symbolize_keys!
  replace(symbolize_keys)
end