Module: TCB::HandlesEvents::ClassMethods
- Defined in:
- lib/tcb/handles_events.rb
Instance Method Summary collapse
- #ensure_reaction(*handlers) ⇒ Object
- #event_handler_registrations ⇒ Object
- #events(*event_classes, stream_id_from_event:) ⇒ Object
- #on(event_class, registration) ⇒ Object
- #outbox_registrations ⇒ Object
- #persist(registration) ⇒ Object
- #persist_registrations ⇒ Object
- #react_with(*handlers) ⇒ Object
Instance Method Details
#ensure_reaction(*handlers) ⇒ Object
32 33 34 |
# File 'lib/tcb/handles_events.rb', line 32 def ensure_reaction(*handlers) handlers.map { |handler| OutboxRegistration.new(event_class: :undefined, handler: handler, outbox_store: nil) } end |
#event_handler_registrations ⇒ Object
48 49 50 |
# File 'lib/tcb/handles_events.rb', line 48 def event_handler_registrations @event_handler_registrations end |
#events(*event_classes, stream_id_from_event:) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/tcb/handles_events.rb', line 40 def events(*event_classes, stream_id_from_event:) PersistRegistration.new( event_classes: event_classes, stream_id_from_event: stream_id_from_event, context: nil ) end |
#on(event_class, registration) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tcb/handles_events.rb', line 17 def on(event_class, registration) case registration in EventHandlerRegistration => r @event_handler_registrations << r.with(event_class: event_class) in [OutboxRegistration, *] => registrations registrations.each do |r| @outbox_registrations << r.with(event_class: event_class) end end end |
#outbox_registrations ⇒ Object
56 57 58 |
# File 'lib/tcb/handles_events.rb', line 56 def outbox_registrations @outbox_registrations end |
#persist(registration) ⇒ Object
36 37 38 |
# File 'lib/tcb/handles_events.rb', line 36 def persist(registration) @persist_registrations << registration end |
#persist_registrations ⇒ Object
52 53 54 |
# File 'lib/tcb/handles_events.rb', line 52 def persist_registrations @persist_registrations end |
#react_with(*handlers) ⇒ Object
28 29 30 |
# File 'lib/tcb/handles_events.rb', line 28 def react_with(*handlers) EventHandlerRegistration.new(event_class: :undefined, handlers: handlers) end |