Class: Hash

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

Direct Known Subclasses

Settingslogic

Instance Method Summary collapse

Instance Method Details

#deep_delete_nilObject



14
15
16
# File 'lib/settingslogic.rb', line 14

def deep_delete_nil
  delete_if{|k, v| v.nil? or v.instance_of?(Hash) && v.deep_delete_nil.empty?}
end

#deep_merge!(other_hash) ⇒ Object



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

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