class Hash

Public Instance Methods

deep_merge(other_hash) click to toggle source
# File lib/rails_config/ext/hash_ext.rb, line 3
def deep_merge(other_hash)
  dup.deep_merge!(other_hash)
end
deep_merge!(other_hash) click to toggle source
# File lib/rails_config/ext/hash_ext.rb, line 8
def deep_merge!(other_hash)
  other_hash.each_pair do |k, v|
    tv = self[k]
    self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
  end
  self
end
deep_stringify_keys() click to toggle source
# File lib/rails_config/ext/hash_ext.rb, line 25
def deep_stringify_keys
  dup.deep_stringify_keys!
end
deep_stringify_keys!() click to toggle source
# File lib/rails_config/ext/hash_ext.rb, line 16
def deep_stringify_keys!
  self.keys.each do |k|
    v=self[k]
    self[k.to_s] = self.delete(k)
    v.deep_stringify_keys! if v.is_a?(Hash)
  end
  self
end
deep_symobolize_keys() click to toggle source
# File lib/rails_config/ext/hash_ext.rb, line 38
def deep_symobolize_keys
  dup.deep_symobolize_keys!
end
deep_symobolize_keys!() click to toggle source
# File lib/rails_config/ext/hash_ext.rb, line 29
def deep_symobolize_keys!
  self.keys.each do |k|
    v=self[k]
    self[k.to_sym] = self.delete(k)
    v.deep_symobolize_keys! if v.is_a?(Hash)
  end
  self
end