Class: Hash

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

Instance Method Summary collapse

Instance Method Details

#deep_compactObject



24
25
26
27
28
29
30
# File 'lib/kapellmeister.rb', line 24

def deep_compact
  each_with_object({}) do |(key, value), hash|
    if (new_value = value.deep_compact)
      hash[key] = new_value
    end
  end
end

#deep_compact!Object



32
33
34
35
36
37
38
# File 'lib/kapellmeister.rb', line 32

def deep_compact!
  each do |key, value|
    if (new_value = value.deep_compact)
      self[key] = new_value
    end
  end
end