Sha256: 6d66ebda8b09cd10adcbaace9c585d3b1e638b6ac948ac3a9a580099150e868f

Contents?: true

Size: 409 Bytes

Versions: 5

Compression:

Stored size: 409 Bytes

Contents

require 'gorillib/object/blank'
module Gorillib
  module Hashlike
    module DeepCompact

      #
      # deep_compact! removes all keys with 'blank?' values in the hash, in place, recursively
      #
      def deep_compact!
        each_pair do |key, val|
          val.deep_compact! if val.respond_to?(:deep_compact!)
          delete(key) if val.blank?
        end
        self
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gorillib-0.6.0 lib/gorillib/hashlike/deep_compact.rb
gorillib-0.5.2 lib/gorillib/hashlike/deep_compact.rb
gorillib-0.5.0 lib/gorillib/hashlike/deep_compact.rb
gorillib-0.4.2 lib/gorillib/hashlike/deep_compact.rb
gorillib-0.4.2pre lib/gorillib/hashlike/deep_compact.rb