Class: Moped::Operation::Write
- Inherits:
-
Object
- Object
- Moped::Operation::Write
- Defined in:
- lib/moped/operation/write.rb
Overview
Encapsulates behaviour for write operations.
Instance Attribute Summary collapse
-
#concern ⇒ Object
The configured write concern.
-
#database ⇒ String
The database the read is from.
- #operation ⇒ Object
Instance Method Summary collapse
-
#execute(node) ⇒ Object
Execute the write operation on the provided node.
-
#initialize(operation, concern) ⇒ Write
constructor
Instantiate the write operation.
Constructor Details
#initialize(operation, concern) ⇒ Write
Instantiate the write operation.
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
#concern ⇒ Object
Returns The configured write concern.
17 18 19 |
# File 'lib/moped/operation/write.rb', line 17 def concern @concern end |
#database ⇒ String
Returns The database the read is from.
17 |
# File 'lib/moped/operation/write.rb', line 17 attr_reader :concern, :database, :operation |
#operation ⇒ Object
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.
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 |