Sha256: c8af8c64880d3be4edc0a65887134391771ad80d98d6f101d4d6a30c533660a5

Contents?: true

Size: 907 Bytes

Versions: 17

Compression:

Stored size: 907 Bytes

Contents

# encoding: utf-8
module Moped
  module WriteConcern

    # Propagating write concerns piggyback a getlasterror command to any write
    # operation with the necessary options.
    #
    # @since 2.0.0
    class Propagate

      # @!attribute operation
      #   @return [ Hash ] The gle operation.
      attr_reader :operation

      # Initialize the propagating write concern.
      #
      # @example Instantiate the write concern.
      #   Moped::WriteConcern::Propagate.new(w: 3)
      #
      # @param [ Hash ] operation The operation to execute.
      #
      # @since 2.0.0
      def initialize(options)
        @operation = { getlasterror: 1 }.merge!(normalize(options))
      end

      private

      def normalize(options)
        opts = {}
        options.each do |key, value|
          opts[key] = value.is_a?(Symbol) ? value.to_s : value
        end
        opts
      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/propagate.rb
moped-2.0.7 lib/moped/write_concern/propagate.rb
moped-2.0.6 lib/moped/write_concern/propagate.rb
moped-2.0.5 lib/moped/write_concern/propagate.rb
moped-2.0.4 lib/moped/write_concern/propagate.rb
moped-2.0.3 lib/moped/write_concern/propagate.rb
moped-2.0.2 lib/moped/write_concern/propagate.rb
moped-2.0.1 lib/moped/write_concern/propagate.rb
moped-2.0.0 lib/moped/write_concern/propagate.rb
moped-2.0.0.rc2 lib/moped/write_concern/propagate.rb
moped-2.0.0.rc1 lib/moped/write_concern/propagate.rb
moped-2.0.0.beta6 lib/moped/write_concern/propagate.rb
moped-2.0.0.beta5 lib/moped/write_concern/propagate.rb
moped-2.0.0.beta4 lib/moped/write_concern/propagate.rb
moped-2.0.0.beta3 lib/moped/write_concern/propagate.rb
moped-2.0.0.beta2 lib/moped/write_concern/propagate.rb
moped-2.0.0.beta lib/moped/write_concern/propagate.rb