Class: OpenSearch::Transport::Redacted

Inherits:
Hash
  • Object
show all
Defined in:
lib/opensearch/transport/redacted.rb

Overview

Class for wrapping a hash that could have sensitive data. When printed, the sensitive values will be redacted.

Since:

  • 6.1.1

Constant Summary collapse

SENSITIVE_KEYS =

The keys whose values will be redacted.

Since:

  • 6.1.1

[ :password,
:pwd ].freeze
STRING_REPLACEMENT =

The replacement string used in place of the value for sensitive keys.

Since:

  • 6.1.1

'<REDACTED>'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(elements = nil) ⇒ Redacted

Returns a new instance of Redacted.

Since:

  • 6.1.1



36
37
38
39
# File 'lib/opensearch/transport/redacted.rb', line 36

def initialize(elements = nil)
  super()
  (elements || {}).each_pair{ |key, value| self[key] = value }
end

Instance Method Details

#inspectString

Get a string representation of the hash.

Returns:

  • (String)

    The string representation of the hash.

Since:

  • 6.1.1



57
58
59
# File 'lib/opensearch/transport/redacted.rb', line 57

def inspect
  redacted_string(:inspect)
end

#to_sString

Get a string representation of the hash.

Returns:

  • (String)

    The string representation of the hash.

Since:

  • 6.1.1



66
67
68
# File 'lib/opensearch/transport/redacted.rb', line 66

def to_s
  redacted_string(:to_s)
end