Class: Moped::Operation::Write

Inherits:
Object
  • Object
show all
Defined in:
lib/moped/operation/write.rb

Overview

Encapsulates behaviour for write operations.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation, concern) ⇒ Write

Instantiate the write operation.

Examples:

Instantiate the write.

Write.new(insert)

Parameters:

Since:

  • 2.0.0



28
29
30
31
32
# File 'lib/moped/operation/write.rb', line 28

def initialize(operation, concern)
  @operation = operation
  @database = operation.database
  @concern = concern
end

Instance Attribute Details

#concernObject

Returns The configured write concern.

Returns:

  • (Object)

    The configured write concern.



17
18
19
# File 'lib/moped/operation/write.rb', line 17

def concern
  @concern
end

#databaseString

Returns The database the read is from.

Returns:

  • (String)

    The database the read is from.



17
# File 'lib/moped/operation/write.rb', line 17

attr_reader :concern, :database, :operation

#operationObject

Since:

  • 2.0.0



17
# File 'lib/moped/operation/write.rb', line 17

attr_reader :concern, :database, :operation

Instance Method Details

#execute(node) ⇒ Object

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.

Examples:

Execute the operation.

write.execute(node)

Parameters:

  • node (Node)

    The node to execute the write on.

Since:

  • 2.0.0



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/moped/operation/write.rb', line 44

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