Module: EventSourcery::Postgres::Reactor::ClassMethods

Defined in:
lib/event_sourcery/postgres/reactor.rb

Overview

Class methods for declaring and querying emitted event types.

Instance Method Summary collapse

Instance Method Details

#emit_eventsArray

Returns an array of the types of events this reactor can emit.

Returns:

  • (Array)

    an array of the types of events this reactor can emit



26
27
28
# File 'lib/event_sourcery/postgres/reactor.rb', line 26

def emit_events
  @emits_event_types ||= [] # rubocop:disable Naming/MemoizedInstanceVariableName
end

#emits_event?(event_type) ⇒ true, false

Will check if this reactor emits the given type of event.

Parameters:

  • event_type

    the event type to check

Returns:

  • (true, false)

    true if it does emit the given event false if not



41
42
43
# File 'lib/event_sourcery/postgres/reactor.rb', line 41

def emits_event?(event_type)
  emit_events.include?(event_type)
end

#emits_events(*event_types) ⇒ Object

Assign the types of events this reactor can emit.

Parameters:

  • event_types

    the types of events this reactor can emit



21
22
23
# File 'lib/event_sourcery/postgres/reactor.rb', line 21

def emits_events(*event_types)
  @emits_event_types = event_types
end

#emits_events?true, false

This will tell you if this reactor emits any type of event.

Returns:

  • (true, false)

    true if this emits events, false if not



33
34
35
# File 'lib/event_sourcery/postgres/reactor.rb', line 33

def emits_events?
  !emit_events.empty?
end