Class: Negroni::ParamFilter
- Inherits:
-
Object
- Object
- Negroni::ParamFilter
- Defined in:
- lib/negroni/param_filter.rb
Overview
ParamFilter is responsible for filtering blacklisted parameters from a request for validation and authentication.
Instance Method Summary collapse
-
#filter(conditions) ⇒ Hash
Filter the ‘conditions` based on @case_insensitive_keys and @strip_whitespace_keys.
-
#initialize(case_insensitive_keys, strip_whitespace_keys) ⇒ ParamFilter
constructor
Creates a new instance of ‘ParamFilter`.
Constructor Details
#initialize(case_insensitive_keys, strip_whitespace_keys) ⇒ ParamFilter
Creates a new instance of ‘ParamFilter`.
14 15 16 17 |
# File 'lib/negroni/param_filter.rb', line 14 def initialize(case_insensitive_keys, strip_whitespace_keys) @case_insensitive_keys = case_insensitive_keys || [] @strip_whitespace_keys = strip_whitespace_keys || [] end |
Instance Method Details
#filter(conditions) ⇒ Hash
Filter the ‘conditions` based on @case_insensitive_keys and
\@strip_whitespace_keys.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/negroni/param_filter.rb', line 25 def filter(conditions) conditions = stringify_params(conditions.dup.to_h) conditions.merge! filtered_hash_by_meth_for_keys(conditions.dup, :downcase, @case_insensitive_keys) conditions.merge! filtered_hash_by_meth_for_keys(conditions.dup, :strip, @strip_whitespace_keys) end |