Class: Hash

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

Overview

extend Hash class to turn keys into symbols

Instance Method Summary collapse

Instance Method Details

#symbolize_keys!Object

turn keys in this hash into symbols


21
22
23
24
25
26
# File 'lib/chatterbot.rb', line 21

def symbolize_keys!
  replace(inject({}) do |hash,(key,value)|
    hash[key.to_sym] = value.is_a?(Hash) ? value.symbolize_keys! : value
    hash
  end)
end