Class: SandthornSequelProjection::Cursor
- Inherits:
-
Object
- Object
- SandthornSequelProjection::Cursor
- Defined in:
- lib/sandthorn_sequel_projection/cursor.rb
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
readonly
Returns the value of attribute batch_size.
-
#last_sequence_number ⇒ Object
readonly
Returns the value of attribute last_sequence_number.
Instance Method Summary collapse
- #get_batch ⇒ Object
-
#initialize(after_sequence_number: 0, event_store: SandthornSequelProjection.default_event_store, batch_size: SandthornSequelProjection.batch_size) ⇒ Cursor
constructor
A new instance of Cursor.
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_size ⇒ Object (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_number ⇒ Object (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_batch ⇒ Object
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 |