Module: ERPC::Redaction

Defined in:
lib/erpc_sdk/errors.rb

Class Method Summary collapse

Class Method Details

.text(value, credential) ⇒ Object



44
45
46
47
48
# File 'lib/erpc_sdk/errors.rb', line 44

def text(value, credential)
  result = value.to_s
  variants(credential).each { |secret| result = result.gsub(secret, "[REDACTED]") unless secret.empty? }
  result
end

.value(value, credential) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/erpc_sdk/errors.rb', line 50

def value(value, credential)
  case value
  when String
    text(value, credential)
  when Array
    value.map { |item| self.value(item, credential) }
  when Hash
    value.to_h do |key, item|
      [text(key, credential), self.value(item, credential)]
    end
  else
    value
  end
end