Class: MudratProjector::TransactionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/mudrat_projector/transaction_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(projection: projection) ⇒ TransactionHandler

Returns a new instance of TransactionHandler.



5
6
7
# File 'lib/mudrat_projector/transaction_handler.rb', line 5

def initialize projection: projection
  @projection = projection
end

Instance Attribute Details

#next_projectorObject

Returns the value of attribute next_projector.



3
4
5
# File 'lib/mudrat_projector/transaction_handler.rb', line 3

def next_projector
  @next_projector
end

Instance Method Details

#<<(transaction) ⇒ Object



9
10
11
12
13
# File 'lib/mudrat_projector/transaction_handler.rb', line 9

def << transaction
  in_projection, leftover = transaction.slice @projection.range.end
  @projection.add_transaction_batch in_projection
  defer leftover if leftover
end

#defer(transaction) ⇒ Object



15
16
17
# File 'lib/mudrat_projector/transaction_handler.rb', line 15

def defer transaction
  next_projector.add_transaction transaction if next_projector
end