Sha256: 7bd6768418c1f26b89ddf861e556ff7ded8d9830e22937659bc8bb1b89c0b7f1

Contents?: true

Size: 869 Bytes

Versions: 17

Compression:

Stored size: 869 Bytes

Contents

# encoding: utf-8
require "moped/write_concern/propagate"
require "moped/write_concern/unverified"

module Moped

  # Provides behaviour on getting the correct write concern for an option.
  #
  # @since 2.0.0
  module WriteConcern
    extend self

    # Get the corresponding write concern for the provided value. If the value
    # is unverified we get that concern, otherwise we get propagate.
    #
    # @example Get the appropriate write concern.
    #   Moped::WriteConcern.get(w: 3)
    #
    # @param [ Symbol, String, Hash ] The value to use to get the concern.
    #
    # @return [ Unverified, Propagate ] The appropriate write concern.
    #
    # @since 2.0.0
    def get(value)
      propagate = value[:w] || value["w"]
      if propagate == 0 || propagate == -1
        Unverified.new
      else
        Propagate.new(value)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/bundler/gems/moped-cf817ca58a85/lib/moped/write_concern.rb
moped-2.0.7 lib/moped/write_concern.rb
moped-2.0.6 lib/moped/write_concern.rb
moped-2.0.5 lib/moped/write_concern.rb
moped-2.0.4 lib/moped/write_concern.rb
moped-2.0.3 lib/moped/write_concern.rb
moped-2.0.2 lib/moped/write_concern.rb
moped-2.0.1 lib/moped/write_concern.rb
moped-2.0.0 lib/moped/write_concern.rb
moped-2.0.0.rc2 lib/moped/write_concern.rb
moped-2.0.0.rc1 lib/moped/write_concern.rb
moped-2.0.0.beta6 lib/moped/write_concern.rb
moped-2.0.0.beta5 lib/moped/write_concern.rb
moped-2.0.0.beta4 lib/moped/write_concern.rb
moped-2.0.0.beta3 lib/moped/write_concern.rb
moped-2.0.0.beta2 lib/moped/write_concern.rb
moped-2.0.0.beta lib/moped/write_concern.rb