Sha256: 5f78c9a32137919bb84b0e22c08a159084e2850fb99e053e2fb1226e673dfef5

Contents?: true

Size: 1.54 KB

Versions: 17

Compression:

Stored size: 1.54 KB

Contents

# encoding: utf-8
module Moped
  module Operation

    # Encapsulates behaviour for write operations.
    #
    # @since 2.0.0
    class Write

      # @!attribute concern
      #   @return [ Object ] The configured write concern.
      # @!attribute database
      #   @return [ String ] The database the read is from.
      # @!attribute operation
      #   @return [ Protocol::Insert, Protocol::Update, Protocol::Delete ]
      #     The write operation.
      attr_reader :concern, :database, :operation

      # Instantiate the write operation.
      #
      # @example Instantiate the write.
      #   Write.new(insert)
      #
      # @param [ Protocol::Insert, Protocol::Update, Protocol::Delete ] operation
      #   The write operation.
      #
      # @since 2.0.0
      def initialize(operation, concern)
        @operation = operation
        @database = operation.database
        @concern = concern
      end

      # Execute the write operation on the provided node. If the write concern
      # is propagating, then the gle command will be piggybacked onto the
      # initial write operation.
      #
      # @example Execute the operation.
      #   write.execute(node)
      #
      # @param [ Node ] node The node to execute the write on.
      #
      # @since 2.0.0
      def execute(node)
        propagate = concern.operation
        if propagate
          node.pipeline do
            node.process(operation)
            node.command(database, propagate)
          end
        else
          node.process(operation)
        end
      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/operation/write.rb
moped-2.0.7 lib/moped/operation/write.rb
moped-2.0.6 lib/moped/operation/write.rb
moped-2.0.5 lib/moped/operation/write.rb
moped-2.0.4 lib/moped/operation/write.rb
moped-2.0.3 lib/moped/operation/write.rb
moped-2.0.2 lib/moped/operation/write.rb
moped-2.0.1 lib/moped/operation/write.rb
moped-2.0.0 lib/moped/operation/write.rb
moped-2.0.0.rc2 lib/moped/operation/write.rb
moped-2.0.0.rc1 lib/moped/operation/write.rb
moped-2.0.0.beta6 lib/moped/operation/write.rb
moped-2.0.0.beta5 lib/moped/operation/write.rb
moped-2.0.0.beta4 lib/moped/operation/write.rb
moped-2.0.0.beta3 lib/moped/operation/write.rb
moped-2.0.0.beta2 lib/moped/operation/write.rb
moped-2.0.0.beta lib/moped/operation/write.rb