123456789_123456789_123456789_123456789_123456789_

Module: Mongo::WriteConcern

Overview

Base module for all write concern specific behavior.

Since:

  • 2.0.0

Constant Summary

Instance Method Summary

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

[ GitHub ]

  
# File '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