Class: RubyEventStore::LinkByEventType

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/link_by_metadata.rb

Instance Method Summary collapse

Constructor Details

#initialize(event_store:, prefix: nil) ⇒ LinkByEventType

Returns a new instance of LinkByEventType.


44
45
46
47
# File 'lib/ruby_event_store/link_by_metadata.rb', line 44

def initialize(event_store:, prefix: nil)
  @event_store = event_store
  @prefix = prefix || "$by_type_"
end

Instance Method Details

#call(event) ⇒ Object


49
50
51
52
53
54
# File 'lib/ruby_event_store/link_by_metadata.rb', line 49

def call(event)
  @event_store.link(
    [event.event_id],
    stream_name: "#{@prefix}#{event.event_type}"
  )
end