Sha256: e2d41613d10bc1368f44149b89660f5c93c34a3256470a558a23c85cb9b0af33

Contents?: true

Size: 747 Bytes

Versions: 23

Compression:

Stored size: 747 Bytes

Contents

module Timber
  module Util
    # @private
    module Hash
      SANITIZED_VALUE = '[sanitized]'.freeze

      extend self

      def deep_compact(hash)
        new_hash = {}

        hash.each do |k, v|
          v = if v.is_a?(::Hash)
            deep_compact(v)
          else
            v
          end

          if v != nil && (!v.respond_to?(:length) || v.length > 0)
            new_hash[k] = v
          end
        end

        new_hash
      end

      def sanitize(hash, keys_to_sanitize)
        hash.each_with_object({}) do |(k, v), h|
          k = k.to_s.downcase
          if keys_to_sanitize.include?(k)
            h[k] = SANITIZED_VALUE
          else
            h[k] = v
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
timber-2.3.1 lib/timber/util/hash.rb
timber-2.3.0 lib/timber/util/hash.rb
timber-2.2.3 lib/timber/util/hash.rb
timber-2.2.2 lib/timber/util/hash.rb
timber-2.2.1 lib/timber/util/hash.rb
timber-2.2.0 lib/timber/util/hash.rb
timber-2.1.10 lib/timber/util/hash.rb
timber-2.1.9 lib/timber/util/hash.rb
timber-2.1.8 lib/timber/util/hash.rb
timber-2.1.7 lib/timber/util/hash.rb
timber-2.1.6 lib/timber/util/hash.rb
timber-2.1.5 lib/timber/util/hash.rb
timber-2.1.4 lib/timber/util/hash.rb
timber-2.1.3 lib/timber/util/hash.rb
timber-2.1.2 lib/timber/util/hash.rb
timber-2.1.1 lib/timber/util/hash.rb
timber-2.1.0 lib/timber/util/hash.rb
timber-2.1.0.rc6 lib/timber/util/hash.rb
timber-2.1.0.rc5 lib/timber/util/hash.rb
timber-2.1.0.rc4 lib/timber/util/hash.rb