module Mongo::WriteConcern

Base module for all write concern specific behavior.

@since 2.0.0

Constants

DEFAULT

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

@since 2.0.0

FSYNC

The file sync write concern.

@since 2.0.0 @deprecated

GET_LAST_ERROR

The GLE command name.

@since 2.0.0 @deprecated

J

The journal write concern.

@since 2.0.0 @deprecated

W

The number of servers write concern.

@since 2.0.0 @deprecated

WTIMEOUT

The wtimeout write concern.

@since 2.0.0 @deprecated

Public Instance Methods

get(options) click to toggle source

Create a write concern object for the provided options.

If options are nil, returns nil.

@example Get a write concern.

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

@param [ Hash ] options The options to instantiate with.

@option options :w [ Integer, String ] The number of servers or the

custom mode to acknowledge.

@option options :j [ true, false ] Whether to acknowledge a write to

the journal.

@option options :fsync [ true, false ] Should the write be synced to

disc.

@option options :wtimeout [ Integer ] The number of milliseconds to

wait for acknowledgement before raising an error.

@return [ nil | Unacknowledged | Acknowledged ] The appropriate concern.

@raise [ Error::InvalidWriteConcern ] If the options are invalid.

@since 2.0.0

# File lib/mongo/write_concern.rb, line 85
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