Class: RubyEventStore::LinkByMetadata
- Inherits:
-
Object
- Object
- RubyEventStore::LinkByMetadata
- Defined in:
- lib/ruby_event_store/link_by_metadata.rb
Direct Known Subclasses
Instance Method Summary collapse
- #call(event) ⇒ Object
-
#initialize(event_store:, key:, prefix: nil) ⇒ LinkByMetadata
constructor
A new instance of LinkByMetadata.
Constructor Details
#initialize(event_store:, key:, prefix: nil) ⇒ LinkByMetadata
Returns a new instance of LinkByMetadata.
5 6 7 8 9 |
# File 'lib/ruby_event_store/link_by_metadata.rb', line 5 def initialize(event_store:, key:, prefix: nil) @event_store = event_store @key = key @prefix = prefix || ["$by", key, nil].join("_") end |
Instance Method Details
#call(event) ⇒ Object
11 12 13 14 15 |
# File 'lib/ruby_event_store/link_by_metadata.rb', line 11 def call(event) return unless event..has_key?(@key) @event_store.link([event.event_id], stream_name: "#{@prefix}#{event..fetch(@key)}") end |