Class: Hash

Inherits:
Object show all
Defined in:
lib/wordnik_ruby_helpers.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) symbolize_and_underscore_keys



320
321
322
323
324
325
# File 'lib/wordnik_ruby_helpers.rb', line 320

def symbolize_and_underscore_keys
  inject({}) do |options, (key, value)|
    options[(key.to_s.underscore.to_sym rescue key) || key] = value
    options
  end
end

- (Object) symbolize_and_underscore_keys!



327
328
329
# File 'lib/wordnik_ruby_helpers.rb', line 327

def symbolize_and_underscore_keys!
  self.replace(self.symbolize_and_underscore_keys)
end