Module: RailsEventStore::AsyncHandler

Defined in:
lib/rails_event_store/async_handler_helpers.rb

Class Method Summary collapse

Class Method Details

.prepended(host_class) ⇒ Object



22
23
24
# File 'lib/rails_event_store/async_handler_helpers.rb', line 22

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

.with(event_store: Rails.configuration.event_store, event_store_locator: nil, serializer: RubyEventStore::Serializers::YAML) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails_event_store/async_handler_helpers.rb', line 9

def self.with(
  event_store: Rails.configuration.event_store,
  event_store_locator: nil,
  serializer: RubyEventStore::Serializers::YAML
)
  Module.new do
    define_method :perform do |payload|
      event_store = event_store_locator.call if event_store_locator
      super(event_store.deserialize(serializer: serializer, **payload.transform_keys(&:to_sym)))
    end
  end
end

.with_defaultsObject



5
6
7
# File 'lib/rails_event_store/async_handler_helpers.rb', line 5

def self.with_defaults
  with
end