Class: Readme::Filter::RejectParams
- Inherits:
-
Object
- Object
- Readme::Filter::RejectParams
- Defined in:
- lib/readme/filter.rb
Instance Method Summary collapse
- #filter(hash) ⇒ Object
-
#initialize(filter_fields) ⇒ RejectParams
constructor
A new instance of RejectParams.
- #pass_through? ⇒ Boolean
Constructor Details
#initialize(filter_fields) ⇒ RejectParams
Returns a new instance of RejectParams.
40 41 42 |
# File 'lib/readme/filter.rb', line 40 def initialize(filter_fields) @rejected_fields = filter_fields end |
Instance Method Details
#filter(hash) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/readme/filter.rb', line 44 def filter(hash) rejected_fields = @rejected_fields.map(&:downcase) rejected_params, allowed_params = hash.partition { |key, _value| rejected_fields.include?(key.downcase) }.map(&:to_h) allowed_params.merge(Filter.redact(rejected_params)) end |
#pass_through? ⇒ Boolean
51 52 53 |
# File 'lib/readme/filter.rb', line 51 def pass_through? false end |