Sha256: 803482d09b52d32f75dcffeee3e1bc4b25a553dac106d47ae214f472c53d4f1d

Contents?: true

Size: 735 Bytes

Versions: 14

Compression:

Stored size: 735 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 != "" && v != {} && v != []
            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

14 entries across 14 versions & 1 rubygems

Version Path
timber-2.0.24 lib/timber/util/hash.rb
timber-2.0.23 lib/timber/util/hash.rb
timber-2.0.22 lib/timber/util/hash.rb
timber-2.0.21 lib/timber/util/hash.rb
timber-2.0.20 lib/timber/util/hash.rb
timber-2.0.19 lib/timber/util/hash.rb
timber-2.0.17 lib/timber/util/hash.rb
timber-2.0.16 lib/timber/util/hash.rb
timber-2.0.15 lib/timber/util/hash.rb
timber-2.0.14 lib/timber/util/hash.rb
timber-2.0.12 lib/timber/util/hash.rb
timber-2.0.11 lib/timber/util/hash.rb
timber-2.0.10 lib/timber/util/hash.rb
timber-2.0.9 lib/timber/util/hash.rb