Module: Estore::Commands::Command
- Included in:
- Append, CatchUpSubscription, LiveSubscription, Ping, ReadBatch, ReadForward
- Defined in:
- lib/estore/commands/base.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
- #handle(message) ⇒ Object
- #initialize(connection) ⇒ Object
- #promise ⇒ Object
- #register! ⇒ Object
- #reject!(error) ⇒ Object
- #remove! ⇒ Object
- #write(command, message = nil) ⇒ Object
Instance Attribute Details
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
4 5 6 |
# File 'lib/estore/commands/base.rb', line 4 def uuid @uuid end |
Instance Method Details
#handle(message) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/estore/commands/base.rb', line 37 def handle() handler = self.class.handlers[.class] if handler send(handler, ) unless handler == :ignore else $stderr.puts "#{message.class} arrived but not handled by "\ "command #{self.class}" end end |
#initialize(connection) ⇒ Object
12 13 14 15 |
# File 'lib/estore/commands/base.rb', line 12 def initialize(connection) @connection = connection @uuid = SecureRandom.uuid end |
#promise ⇒ Object
33 34 35 |
# File 'lib/estore/commands/base.rb', line 33 def promise @promise ||= Promise.new(@uuid) end |
#register! ⇒ Object
17 18 19 |
# File 'lib/estore/commands/base.rb', line 17 def register! @connection.register(self) end |
#reject!(error) ⇒ Object
25 26 27 |
# File 'lib/estore/commands/base.rb', line 25 def reject!(error) @promise.reject(error) if @promise end |
#remove! ⇒ Object
21 22 23 |
# File 'lib/estore/commands/base.rb', line 21 def remove! @connection.remove(self) end |
#write(command, message = nil) ⇒ Object
29 30 31 |
# File 'lib/estore/commands/base.rb', line 29 def write(command, = nil) @connection.write(@uuid, command, ) end |