Module: RailsEventStore::AsyncHandlerJobIdOnly

Defined in:
lib/rails_event_store/async_handler_helpers.rb

Class Method Summary collapse

Class Method Details

.prepended(host_class) ⇒ Object



44
45
46
# File 'lib/rails_event_store/async_handler_helpers.rb', line 44

def self.prepended(host_class)
  host_class.prepend with_defaults
end

.with(event_store: Rails.configuration.event_store, event_store_locator: nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rails_event_store/async_handler_helpers.rb', line 32

def self.with(
  event_store: Rails.configuration.event_store,
  event_store_locator: nil
)
  Module.new do
    define_method :perform do |payload|
      event_store = event_store_locator.call if event_store_locator
      super(event_store.read.event(payload.fetch("event_id")))
    end
  end
end

.with_defaultsObject



28
29
30
# File 'lib/rails_event_store/async_handler_helpers.rb', line 28

def self.with_defaults
  with
end