Module: Mongo::WriteConcern

Extended by:
WriteConcern
Included in:
WriteConcern
Defined in:
build/ruby-driver-v2.19/lib/mongo/write_concern.rb,
build/ruby-driver-v2.19/lib/mongo/write_concern/base.rb,
build/ruby-driver-v2.19/lib/mongo/write_concern/acknowledged.rb,
build/ruby-driver-v2.19/lib/mongo/write_concern/unacknowledged.rb

Overview

Base module for all write concern specific behavior.

Since:

  • 2.0.0

Defined Under Namespace

Classes: Acknowledged, Base, Unacknowledged

Constant Summary collapse

W =
Deprecated.

The number of servers write concern.

Since:

  • 2.0.0

:w.freeze
J =
Deprecated.

The journal write concern.

Since:

  • 2.0.0

:j.freeze
FSYNC =
Deprecated.

The file sync write concern.

Since:

  • 2.0.0

:fsync.freeze
WTIMEOUT =
Deprecated.

The wtimeout write concern.

Since:

  • 2.0.0

:wtimeout.freeze
GET_LAST_ERROR =
Deprecated.

The GLE command name.

Since:

  • 2.0.0

:getlasterror.freeze
DEFAULT =

The default write concern is to acknowledge on a single server.

Since:

  • 2.0.0

{ }.freeze

Instance Method Summary collapse

Instance Method Details

#get(options) ⇒ nil | Unacknowledged | Acknowledged

Create a write concern object for the provided options.

If options are nil, returns nil.

Examples:

Get a write concern.

Mongo::WriteConcern.get(:w => 1)

Parameters:

  • options (Hash)

    The options to instantiate with.

Options Hash (options):

  • :w (Integer, String)

    The number of servers or the custom mode to acknowledge.

  • :j (true, false)

    Whether to acknowledge a write to the journal.

  • :fsync (true, false)

    Should the write be synced to disc.

  • :wtimeout (Integer)

    The number of milliseconds to wait for acknowledgement before raising an error.

Returns:

Raises:

Since:

  • 2.0.0



88
89
90
91
92
93
94
95
96
97
# File 'build/ruby-driver-v2.19/lib/mongo/write_concern.rb', line 88

def get(options)
  return options if options.is_a?(Base)
  if options
    if (options[:w] || options['w']) == 0
      Unacknowledged.new(options)
    else
      Acknowledged.new(options)
    end
  end
end