Class: SandthornDriverSequel2::EventQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/sandthorn_driver_sequel_2/event_query.rb

Instance Method Summary collapse

Constructor Details

#initialize(storage) ⇒ EventQuery

Returns a new instance of EventQuery.



3
4
5
# File 'lib/sandthorn_driver_sequel_2/event_query.rb', line 3

def initialize(storage)
  @storage = storage
end

Instance Method Details

#build(aggregate_types: [], take: 0, after_sequence_number: 0) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sandthorn_driver_sequel_2/event_query.rb', line 7

def build(
  aggregate_types: [],
  take: 0,
  after_sequence_number: 0)

  aggregate_types.map!(&:to_s)

  query = storage.events
  query = add_aggregate_types(query, aggregate_types)
  query = add_sequence_number(query, after_sequence_number)
  query = add_select(query)
  query = add_limit(query, take)
  @query = query.order(:sequence_number)
end

#eventsObject



22
23
24
# File 'lib/sandthorn_driver_sequel_2/event_query.rb', line 22

def events
  @query.all
end