Module: Moped::WriteConcern

Extended by:
WriteConcern
Included in:
WriteConcern
Defined in:
lib/moped/write_concern.rb,
lib/moped/write_concern/propagate.rb,
lib/moped/write_concern/unverified.rb

Overview

Provides behaviour on getting the correct write concern for an option.

Since:

  • 2.0.0

Defined Under Namespace

Classes: Propagate, Unverified

Instance Method Summary collapse

Instance Method Details

#get(value) ⇒ Unverified, Propagate

Get the corresponding write concern for the provided value. If the value is unverified we get that concern, otherwise we get propagate.

Examples:

Get the appropriate write concern.

Moped::WriteConcern.get(w: 3)

Parameters:

  • The (Symbol, String, Hash)

    value to use to get the concern.

Returns:

Since:

  • 2.0.0



24
25
26
27
28
29
30
31
# File 'lib/moped/write_concern.rb', line 24

def get(value)
  propagate = value[:w] || value["w"]
  if propagate == 0 || propagate == -1
    Unverified.new
  else
    Propagate.new(value)
  end
end