Module: ActiveEventStore
- Defined in:
- lib/active_event_store/version.rb,
lib/active_event_store.rb,
lib/active_event_store/event.rb,
lib/active_event_store/config.rb,
lib/active_event_store/engine.rb,
lib/active_event_store/mapper.rb,
lib/active_event_store/mapping.rb,
lib/active_event_store/test_helper.rb,
lib/active_event_store/domain_event.rb,
lib/active_event_store/subscriber_job.rb,
lib/active_event_store/rspec/have_published_event.rb,
lib/active_event_store/test_helper/event_published_matcher.rb,
lib/active_event_store/rspec/have_enqueued_async_subscriber_for.rb
Overview
Defined Under Namespace
Modules: TestHelper
Classes: Config, DomainEvent, Engine, Event, HaveEnqueuedAsyncSubscriberFor, HavePublishedEvent, Mapper, Mapping, SubscriberJob
Constant Summary
collapse
- VERSION =
"1.2.0"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.event_store ⇒ Object
Underlying RailsEventStore
18
19
20
|
# File 'lib/active_event_store.rb', line 18
def event_store
@event_store
end
|
Class Method Details
.config ⇒ Object
24
25
26
|
# File 'lib/active_event_store.rb', line 24
def config
@config ||= Config.new
end
|
.mapping ⇒ Object
20
21
22
|
# File 'lib/active_event_store.rb', line 20
def mapping
@mapping ||= Mapping.new
end
|
.publish(event, **options) ⇒ Object
53
54
55
|
# File 'lib/active_event_store.rb', line 53
def publish(event, **options)
event_store.publish event, **options
end
|
.subscribe(subscriber = nil, to: nil, sync: false, &block) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/active_event_store.rb', line 28
def subscribe(subscriber = nil, to: nil, sync: false, &block)
subscriber ||= block
to ||= infer_event_from_subscriber(subscriber) if subscriber.is_a?(Module)
if to.nil?
raise ArgumentError, "Couldn't infer event from subscriber. " \
"Please, specify event using `to:` option"
end
identifier =
if to.is_a?(Class) && to <= ActiveEventStore::Event
mapping.register_event to
to.identifier
else
to
end
subscriber = SubscriberJob.from(subscriber) unless sync
event_store.subscribe subscriber, to: [identifier]
end
|