Class: Yes::Core::Commands::Notifier
- Inherits:
-
Object
- Object
- Yes::Core::Commands::Notifier
- Defined in:
- lib/yes/core/commands/notifier.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Notifier
constructor
A new instance of Notifier.
-
#notify_batch_finished(batch_id, transaction = nil, responses = nil) ⇒ Object
Implement this method to notify that a batch has finished processing.
-
#notify_batch_started(batch_id, transaction = nil, commands = nil) ⇒ Object
Implement this method to notify that a batch has started processing.
-
#notify_command_response(cmd_response) ⇒ Object
Implement this method to notify that a command response has been received.
-
#with_batch_notification(batch_id, commands, transaction = nil) { ... } ⇒ Array<Response>
Wraps the given block in a batch notification.
Constructor Details
#initialize(options = {}) ⇒ Notifier
Returns a new instance of Notifier.
14 15 16 |
# File 'lib/yes/core/commands/notifier.rb', line 14 def initialize( = {}) @channel = [:channel] end |
Class Method Details
.with_batch_notification(notifiers, batch_id, commands, transaction = nil) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/yes/core/commands/notifier.rb', line 55 def self.with_batch_notification(notifiers, batch_id, commands, transaction = nil) notifiers.each { _1.notify_batch_started(batch_id, transaction, commands) } response = yield notifiers.each { _1.notify_batch_finished(batch_id, transaction, response) } response end |
Instance Method Details
#notify_batch_finished(batch_id, transaction = nil, responses = nil) ⇒ Object
Implement this method to notify that a batch has finished processing
30 31 32 |
# File 'lib/yes/core/commands/notifier.rb', line 30 def notify_batch_finished(batch_id, transaction = nil, responses = nil) raise NotImplementedError end |
#notify_batch_started(batch_id, transaction = nil, commands = nil) ⇒ Object
Implement this method to notify that a batch has started processing
22 23 24 |
# File 'lib/yes/core/commands/notifier.rb', line 22 def notify_batch_started(batch_id, transaction = nil, commands = nil) raise NotImplementedError end |
#notify_command_response(cmd_response) ⇒ Object
Implement this method to notify that a command response has been received
36 37 38 |
# File 'lib/yes/core/commands/notifier.rb', line 36 def notify_command_response(cmd_response) raise NotImplementedError end |
#with_batch_notification(batch_id, commands, transaction = nil) { ... } ⇒ Array<Response>
Wraps the given block in a batch notification.
47 48 49 50 51 52 53 |
# File 'lib/yes/core/commands/notifier.rb', line 47 def with_batch_notification(batch_id, commands, transaction = nil) notify_batch_started(batch_id, transaction, commands) response = yield notify_batch_finished(batch_id, transaction, response) response end |