class OpenSearch::Transport::Redacted
Class for wrapping a hash that could have sensitive data. When printed, the sensitive values will be redacted.
@since 6.1.1
Constants
- SENSITIVE_KEYS
The keys whose values will be redacted.
@since 6.1.1
- STRING_REPLACEMENT
The replacement string used in place of the value for sensitive keys.
@since 6.1.1
Public Class Methods
new(elements = nil)
click to toggle source
Calls superclass method
# File lib/opensearch/transport/redacted.rb, line 36 def initialize(elements = nil) super() (elements || {}).each_pair{ |key, value| self[key] = value } end
Public Instance Methods
inspect()
click to toggle source
Get a string representation of the hash.
@return [ String ] The string representation of the hash.
@since 6.1.1
# File lib/opensearch/transport/redacted.rb, line 57 def inspect redacted_string(:inspect) end
to_s()
click to toggle source
Get a string representation of the hash.
@return [ String ] The string representation of the hash.
@since 6.1.1
# File lib/opensearch/transport/redacted.rb, line 66 def to_s redacted_string(:to_s) end
Private Instance Methods
redact(k, v, method)
click to toggle source
# File lib/opensearch/transport/redacted.rb, line 78 def redact(k, v, method) return STRING_REPLACEMENT if SENSITIVE_KEYS.include?(k.to_sym) v.send(method) end
redacted_string(method)
click to toggle source
# File lib/opensearch/transport/redacted.rb, line 72 def redacted_string(method) '{' + reduce([]) do |list, (k, v)| list << "#{k.send(method)}=>#{redact(k, v, method)}" end.join(', ') + '}' end