Class: Julewire::Redaction::StringRedactor
- Inherits:
-
Object
- Object
- Julewire::Redaction::StringRedactor
- Defined in:
- lib/julewire/redaction/string_redactor.rb
Instance Method Summary collapse
- #call(value) ⇒ Object
-
#initialize(matcher:, mask:, authorization_header: true) ⇒ StringRedactor
constructor
A new instance of StringRedactor.
Constructor Details
#initialize(matcher:, mask:, authorization_header: true) ⇒ StringRedactor
Returns a new instance of StringRedactor.
6 7 8 9 10 11 |
# File 'lib/julewire/redaction/string_redactor.rb', line 6 def initialize(matcher:, mask:, authorization_header: true) @matcher = matcher @mask = mask.to_s @authorization_header = @redact_pairs = !@matcher.empty? end |
Instance Method Details
#call(value) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/julewire/redaction/string_redactor.rb', line 13 def call(value) return value unless value.is_a?(String) has_colon = value.include?(":") has_equals = value.include?("=") return value unless redaction_possible?(has_colon, has_equals) redacted = value.dup redact_header_lines!(redacted) if has_colon if @redact_pairs && @matcher.string_key_possible?(value) redact_pair_values!(value, redacted, has_colon: has_colon, has_equals: has_equals) end redacted end |