class ActiveSupport::ParameterFilter
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/active_support/parameter_filter.rbs class ActiveSupport::ParameterFilter def compiled_filter: () -> untyped end
end])
v.reverse! if /secret/i.match?(k)
ActiveSupport::ParameterFilter.new([-> (k, v) do
# Reverses values for keys that match /secret/i.<br><br>ActiveSupport::ParameterFilter.new()
# Does not change ‘{ file: { code: “xxxx” } }`.
# Replaces the value for :code in `{ credit_card: { code: “xxxx” } }`.
ActiveSupport::ParameterFilter.new([/Apinz/, /Apin_/])
# substring, such as “shipping_id”.
# “pin_”. Does not match keys that otherwise include “pin” as a
# Replaces values for the exact key “pin” and for keys that begin with
ActiveSupport::ParameterFilter.new([:foo, “bar”])
# Replaces values with “[FILTERED]” for keys that match /foo|bar/i.<br><br>ActiveSupport::ParameterFilter.new()
# Replaces values with “[FILTERED]” for keys that match /password/i.
then be mutated as desired using methods such as String#replace
.
and of any nested Hash
es will be passed to it. The value or key can
If a proc is given as a filter, each key and value of the Hash
-like"credit_card.number"
.
Matching based on nested keys is possible by using dot notation, e.g.
keys match one of the specified filters.ParameterFilter
replaces values in a Hash
-like object if their
def compiled_filter
Experimental RBS support (using type sampling data from the type_fusion
project).
def compiled_filter: () -> untyped
This signature was generated using 1 sample from 1 application.
def compiled_filter @compiled_filter ||= CompiledFilter.compile(@filters, mask: @mask) end
def filter(params)
def filter(params) compiled_filter.call(params) end
def filter_param(key, value)
def filter_param(key, value) @filters.empty? ? value : compiled_filter.value_for_key(key, value) end
def initialize(filters = [], mask: FILTERED)
==== Options
For +Proc+ filters, key, value, and optional original hash is passed to block arguments.
Other types of filters are treated as +String+ using +to_s+.
Create instance with given filters. Supported type of filters are +String+, +Regexp+, and +Proc+.
def initialize(filters = [], mask: FILTERED) @filters = filters @mask = mask end