Class: Seams::Events::Adapter
- Inherits:
-
Object
- Object
- Seams::Events::Adapter
- Defined in:
- lib/seams/events/adapter.rb
Overview
Abstract base class for event-bus adapters. Real adapters wrap a transport (ActiveSupport::Notifications, an external queue, etc.) and implement the three primitives below.
Direct Known Subclasses
Instance Method Summary collapse
-
#publish(_event_name, _payload) ⇒ void
Deliver an event (a name plus a Hash payload) to the transport.
-
#subscribe(_event_name) ⇒ Object
Register a block to run when the named event is published.
-
#unsubscribe(_subscriber) ⇒ void
Detach a previously-registered subscriber (the handle #subscribe returned).
Instance Method Details
#publish(_event_name, _payload) ⇒ void
This method returns an undefined value.
Deliver an event (a name plus a Hash payload) to the transport.
14 15 16 |
# File 'lib/seams/events/adapter.rb', line 14 def publish(_event_name, _payload) raise NotImplementedError, "#{self.class} must implement #publish" end |
#subscribe(_event_name) ⇒ Object
Register a block to run when the named event is published.
21 22 23 |
# File 'lib/seams/events/adapter.rb', line 21 def subscribe(_event_name, &) raise NotImplementedError, "#{self.class} must implement #subscribe" end |
#unsubscribe(_subscriber) ⇒ void
This method returns an undefined value.
Detach a previously-registered subscriber (the handle #subscribe returned).
28 29 30 |
# File 'lib/seams/events/adapter.rb', line 28 def unsubscribe(_subscriber) raise NotImplementedError, "#{self.class} must implement #unsubscribe" end |