Module: Mongo::WriteConcern::Normalizable

Included in:
Acknowledged, Unacknowledged
Defined in:
lib/mongo/write_concern/normalizable.rb

Overview

Defines default behavior for write concerns and provides a factory interface to get a proper object from options.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsHash (readonly)

Returns The write concern options.

Returns:

  • (Hash)

    The write concern options.

Since:

  • 2.0.0



25
26
27
# File 'lib/mongo/write_concern/normalizable.rb', line 25

def options
  @options
end

Instance Method Details

#initialize(options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Instantiate a new write concern given the options.

Examples:

Instantiate a new write concern mode.

Mongo::WriteConcern.new(: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.

Since:

  • 2.0.0



46
47
48
49
# File 'lib/mongo/write_concern/normalizable.rb', line 46

def initialize(options)
  opts =  Options::Mapper.transform_keys_to_symbols(options)
  @options = Options::Mapper.transform_values_to_strings(opts).freeze
end