class Kiev::ParamFilter
Constants
- FILTERED
Attributes
filtered_params[R]
ignored_params[R]
Public Class Methods
filter(params, filtered_params, ignored_params)
click to toggle source
# File lib/kiev/param_filter.rb, line 7 def self.filter(params, filtered_params, ignored_params) new(filtered_params, ignored_params).call(params) end
new(filtered_params, ignored_params)
click to toggle source
# File lib/kiev/param_filter.rb, line 11 def initialize(filtered_params, ignored_params) @filtered_params = normalize(filtered_params) @ignored_params = normalize(ignored_params) end
Public Instance Methods
call(params)
click to toggle source
# File lib/kiev/param_filter.rb, line 16 def call(params) params.each_with_object({}) do |(key, value), acc| next if ignored_params.include?(key.to_s) 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.to_s) && !value.is_a?(Hash) FILTERED elsif value.is_a?(Hash) call(value) else value end end end
Private Instance Methods
normalize(params)
click to toggle source
# File lib/kiev/param_filter.rb, line 43 def normalize(params) Set.new(params.map(&:to_s)) end