Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/qat/core_ext/object/deep_compact.rb
Overview
class Hash
Instance Method Summary collapse
-
#deep_compact ⇒ Hash
Returns a copy of the current hash with non nil values throughout all tree.
-
#deep_compact! ⇒ Hash
Replaces the current hash with non nil values throughout all tree.
Instance Method Details
#deep_compact ⇒ Hash
Returns a copy of the current hash with non nil values throughout all tree
34 35 36 |
# File 'lib/qat/core_ext/object/deep_compact.rb', line 34 def deep_compact deep_dup.deep_compact! end |
#deep_compact! ⇒ Hash
Replaces the current hash with non nil values throughout all tree
67 68 69 70 71 72 |
# File 'lib/qat/core_ext/object/deep_compact.rb', line 67 def deep_compact! self.compact! self.each do |key, value| self[key] = value.respond_to?(:deep_compact!) ? value.deep_compact! : value end end |