Class: SandthornSequelProjection::Cursor

Inherits:
Object
  • Object
show all
Defined in:
lib/sandthorn_sequel_projection/cursor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(after_sequence_number: 0, event_store: SandthornSequelProjection.default_event_store, batch_size: SandthornSequelProjection.batch_size) ⇒ Cursor

Returns a new instance of Cursor.



6
7
8
9
10
11
12
13
# File 'lib/sandthorn_sequel_projection/cursor.rb', line 6

def initialize(
    after_sequence_number: 0,
    event_store: SandthornSequelProjection.default_event_store,
    batch_size: SandthornSequelProjection.batch_size)
  @last_sequence_number = after_sequence_number
  @batch_size = batch_size
  @event_store = event_store
end

Instance Attribute Details

#batch_sizeObject (readonly)

Returns the value of attribute batch_size.



4
5
6
# File 'lib/sandthorn_sequel_projection/cursor.rb', line 4

def batch_size
  @batch_size
end

#last_sequence_numberObject (readonly)

Returns the value of attribute last_sequence_number.



4
5
6
# File 'lib/sandthorn_sequel_projection/cursor.rb', line 4

def last_sequence_number
  @last_sequence_number
end

Instance Method Details

#get_batchObject



15
16
17
18
19
20
21
22
# File 'lib/sandthorn_sequel_projection/cursor.rb', line 15

def get_batch
  events = get_events
  events.tap do |events|
    if last_event = events.last
      @last_sequence_number = last_event[:sequence_number]
    end
  end
end