Sha256: d6e83ee524b5e61fb63eb3808e49123e2f66efc9755b6bd0232ecc1af2640e56

Contents?: true

Size: 799 Bytes

Versions: 9

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

module Kiev
  module ParamFilter
    FILTERED = "[FILTERED]"

    def self.filter(params, filtered_params, ignored_params)
      params.each_with_object({}) do |(key, value), acc|
        next if ignored_params.include?(key)

        if defined?(ActionDispatch) && value.is_a?(ActionDispatch::Http::UploadedFile)
          value = {
            original_filename: value.original_filename,
            content_type: value.content_type,
            headers: value.headers
          }
        end

        acc[key] =
          if filtered_params.include?(key) && !value.is_a?(Hash)
            FILTERED
          elsif value.is_a?(Hash)
            filter(value, filtered_params, ignored_params)
          else
            value
          end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kiev-4.5.0 lib/kiev/param_filter.rb
kiev-4.4.0 lib/kiev/param_filter.rb
kiev-4.3.0 lib/kiev/param_filter.rb
kiev-4.2.0 lib/kiev/param_filter.rb
kiev-4.1.0 lib/kiev/param_filter.rb
kiev-4.0.0 lib/kiev/param_filter.rb
kiev-3.0.0 lib/kiev/param_filter.rb
kiev-2.8.0 lib/kiev/param_filter.rb
kiev-2.7.3 lib/kiev/param_filter.rb