Class: EventStoreRuby::EventFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/eventstore_ruby/event_filter.rb

Overview

Describes the subset of events to select when querying the store. Immutable and thread-safe.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_types:, payload_predicates: nil) ⇒ EventFilter

event_types: [String] (required, can be empty for “all types”) payload_predicates: Array<Hash> (optional) – each hash is a partial payload that must match.



9
10
11
12
13
14
15
16
17
# File 'lib/eventstore_ruby/event_filter.rb', line 9

def initialize(event_types:, payload_predicates: nil)
  unless event_types.is_a?(Array) && event_types.all? { |t| t.is_a?(String) }
    raise ArgumentError, 'event_types must be an array of strings'
  end

  @event_types = event_types.freeze
  @payload_predicates = payload_predicates&.map(&:freeze)&.freeze
  freeze
end

Instance Attribute Details

#event_typesObject (readonly)

Returns the value of attribute event_types.



5
6
7
# File 'lib/eventstore_ruby/event_filter.rb', line 5

def event_types
  @event_types
end

#payload_predicatesObject (readonly)

Returns the value of attribute payload_predicates.



5
6
7
# File 'lib/eventstore_ruby/event_filter.rb', line 5

def payload_predicates
  @payload_predicates
end