Method: Mongo::Options::Redacted#select!

Defined in:
lib/mongo/options/redacted.rb

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

Only keeps pairs for which the block returns true.

Examples:

Remove pairs from this object for which the block does not return true.

options.select! { |k, v| k =~ /ssl/ }

Yield Parameters:

  • The (String, Object)

    key as a string and its value.

Returns:

Since:

  • 2.1.0



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