class Readme::Filter::AllowOnly

Public Class Methods

new(filter_fields) click to toggle source
# File lib/readme/filter.rb, line 23
def initialize(filter_fields)
  @allowed_fields = filter_fields
end

Public Instance Methods

filter(hash) click to toggle source
# File lib/readme/filter.rb, line 27
def filter(hash)
  allowed_fields = @allowed_fields.map(&:downcase)
  allowed_params, rejected_params = hash.partition { |key, _value| allowed_fields.include?(key.downcase) }.map(&:to_h)

  allowed_params.merge(Filter.redact(rejected_params))
end
pass_through?() click to toggle source
# File lib/readme/filter.rb, line 34
def pass_through?
  false
end