Sha256: 92d9403c6953f232f6e33840e85b4e0f7a0cc59362c89a0dad8562e3fefe8261

Contents?: true

Size: 828 Bytes

Versions: 7

Compression:

Stored size: 828 Bytes

Contents

module Rack::ActionLogger
  module ParameterFiltering
    FILTERED = '[FILTERED]'.freeze # :nodoc:

    class << self

      def apply_filter(original_params, compiled_filters)
        filtered_params = {}

        original_params.each do |key, value|
          if compiled_filters.any? { |r| key =~ r }
            value = FILTERED
          elsif value.is_a?(Hash)
            value = apply_filter(value, compiled_filters)
          elsif value.is_a?(Array)
            value = value.map { |v| v.is_a?(Hash) ? apply_filter(v, compiled_filters) : v }
          end

          filtered_params[key] = value
        end

        filtered_params
      end

      def compile(filters)
        filter_strings = filters.map(&:to_s)
        filter_strings.map { |item| Regexp.compile(Regexp.escape(item)) }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rack-action_logger-0.1.8 lib/rack/action_logger/parameter_filtering.rb
rack-action_logger-0.1.7 lib/rack/action_logger/parameter_filtering.rb
rack-action_logger-0.1.6 lib/rack/action_logger/parameter_filtering.rb
rack-action_logger-0.1.5 lib/rack/action_logger/parameter_filtering.rb
rack-action_logger-0.1.4 lib/rack/action_logger/parameter_filtering.rb
rack-action_logger-0.1.3 lib/rack/action_logger/parameter_filtering.rb
rack-action_logger-0.1.2 lib/rack/action_logger/parameter_filtering.rb