Redacted — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::Options::Redacted

Inherits:

BSON::Document

Defined in:

lib/mongo/options/redacted.rb

Overview

Class for wrapping options that could be sensitive. When printed, the sensitive values will be redacted.

Constant Summarycollapse

SENSITIVE_OPTIONS =

The options whose values will be redacted.

[ :password, :pwd ].freeze

STRING_REPLACEMENT =

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

''.freeze

Instance Method Summarycollapse

Instance Method Details

#has_key?(key) ⇒ true, false Also known as:key?

Whether these options contain a given key.

66 67 68 # File 'lib/mongo/options/redacted.rb', line 66 def has_key?(key) super(convert_key(key)) end

#inspect ⇒ String

Get a string representation of the options.

43 44 45 # File 'lib/mongo/options/redacted.rb', line 43 def inspect redacted_string(:inspect) end

#reject {|The| ... } ⇒ Options::Redacted

Returns a new options object consisting of pairs for which the block returns false.

| 81 82 83 84 | # File 'lib/mongo/options/redacted.rb', line 81 def reject(&block) new_options = dup new_options.reject!(&block) || new_options end | | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------- |

#reject! {|The| ... } ⇒ Options::Redacted?

Only keeps pairs for which the block returns false.

| 96 97 98 99 100 101 102 103 104 105 106 | # File 'lib/mongo/options/redacted.rb', line 96 def reject! if block_given? n_keys = keys.size keys.each do |key| delete(key) if yield(key, self[key]) end n_keys == keys.size ? nil : self else to_enum end end | | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

#select {|The| ... } ⇒ Options::Redacted

Returns a new options object consisting of pairs for which the block returns true.

| 118 119 120 121 | # File 'lib/mongo/options/redacted.rb', line 118 def select(&block) new_options = dup new_options.select!(&block) || new_options end | | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |

#select! {|The| ... } ⇒ Options::Redacted?

Only keeps pairs for which the block returns true.

| 133 134 135 136 137 138 139 140 141 142 143 | # File 'lib/mongo/options/redacted.rb', line 133 def select! if block_given? n_keys = keys.size keys.each do |key| delete(key) unless yield(key, self[key]) end n_keys == keys.size ? nil : self else to_enum end end | | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

#to_s ⇒ String

Get a string representation of the options.

52 53 54 # File 'lib/mongo/options/redacted.rb', line 52 def to_s redacted_string(:to_s) end