Class: Estore::Commands::Append
- Inherits:
-
Object
- Object
- Estore::Commands::Append
- Includes:
- Command
- Defined in:
- lib/estore/commands/append.rb
Instance Attribute Summary
Attributes included from Command
Instance Method Summary collapse
- #call ⇒ Object
- #completed(response) ⇒ Object
-
#initialize(connection, stream, events, options = {}) ⇒ Append
constructor
A new instance of Append.
Methods included from Command
#handle, #promise, #register!, #reject!, #remove!, #write
Constructor Details
#initialize(connection, stream, events, options = {}) ⇒ Append
Returns a new instance of Append.
8 9 10 11 |
# File 'lib/estore/commands/append.rb', line 8 def initialize(connection, stream, events, = {}) super(connection) @stream, @events, = stream, events, end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/estore/commands/append.rb', line 13 def call register! msg = WriteEvents.new( event_stream_id: @stream, expected_version: [:expected_version] || -2, events: Array(@events).map { |event| new_event(event) }, require_master: true ) write('WriteEvents', msg) promise end |
#completed(response) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/estore/commands/append.rb', line 27 def completed(response) remove! if response.result == OperationResult::Success promise.fulfill(response) else promise.reject Estore::WriteEventsError.new(response) end end |