Class: Hash

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

Overview

monkey patch functionally similar to the one provided by ActiveSupport

Instance Method Summary collapse

Instance Method Details

#symbolize_keysObject

recursively symolizes keys in a Hash that are strings does not modify the original hash; returns a new hash



5
6
7
8
9
10
11
12
# File 'lib/clone_remote_db/hash.rb', line 5

def symbolize_keys
  self.to_a.reduce({}) do |acc, (key, val)|
    val = symbolize_keys(val) if val.is_a?(Hash)
    key = key.to_sym if key.is_a?(String)
    acc[key] = val
    acc
  end
end