Class: Hermes::Logger::ParamsFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/hermes/logger/params_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(sensitive_keywords: SENSITIVE_ATTRIBUTES_KEYWORDS, stripped_value: STRIPPED_VALUE) ⇒ ParamsFilter

Returns a new instance of ParamsFilter.



13
14
15
16
# File 'lib/hermes/logger/params_filter.rb', line 13

def initialize(sensitive_keywords: SENSITIVE_ATTRIBUTES_KEYWORDS, stripped_value: STRIPPED_VALUE)
  @sensitive_keywords = sensitive_keywords
  @stripped_value = stripped_value
end

Instance Method Details

#call(attribute, value) ⇒ Object



18
19
20
21
22
# File 'lib/hermes/logger/params_filter.rb', line 18

def call(attribute, value)
  if sensitive_keywords.any? { |sensitive_attribute| match?(sensitive_attribute, attribute) } && value.respond_to?(:to_str)
    value.gsub!(value, stripped_value)
  end
end