Class: Mongo::Options::Redacted
- Inherits:
-
BSON::Document
- Object
- BSON::Document
- Mongo::Options::Redacted
- Defined in:
- build/ruby-driver-v2.19/lib/mongo/options/redacted.rb
Overview
Class for wrapping options that could be sensitive. When printed, the sensitive values will be redacted.
Constant Summary collapse
- 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.
'<REDACTED>'.freeze
Instance Method Summary collapse
-
#has_key?(key) ⇒ true, false
(also: #key?)
Whether these options contain a given key.
-
#inspect ⇒ String
Get a string representation of the options.
-
#reject {|The| ... } ⇒ Options::Redacted
Returns a new options object consisting of pairs for which the block returns false.
-
#reject! {|The| ... } ⇒ Options::Redacted?
Only keeps pairs for which the block returns false.
-
#select {|The| ... } ⇒ Options::Redacted
Returns a new options object consisting of pairs for which the block returns true.
-
#select! {|The| ... } ⇒ Options::Redacted?
Only keeps pairs for which the block returns true.
-
#to_s ⇒ String
Get a string representation of the options.
Instance Method Details
#has_key?(key) ⇒ true, false Also known as: key?
Whether these options contain a given key.
66 67 68 |
# File 'build/ruby-driver-v2.19/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 'build/ruby-driver-v2.19/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 'build/ruby-driver-v2.19/lib/mongo/options/redacted.rb', line 81 def reject(&block) = dup .reject!(&block) || 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 'build/ruby-driver-v2.19/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 'build/ruby-driver-v2.19/lib/mongo/options/redacted.rb', line 118 def select(&block) = dup .select!(&block) || 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 'build/ruby-driver-v2.19/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 'build/ruby-driver-v2.19/lib/mongo/options/redacted.rb', line 52 def to_s redacted_string(:to_s) end |