Class: MudratProjector::TransactionHandler
- Inherits:
-
Object
- Object
- MudratProjector::TransactionHandler
- Defined in:
- lib/mudrat_projector/transaction_handler.rb
Instance Attribute Summary collapse
-
#next_projector ⇒ Object
Returns the value of attribute next_projector.
Instance Method Summary collapse
- #<<(transaction) ⇒ Object
- #defer(transaction) ⇒ Object
-
#initialize(projection: projection) ⇒ TransactionHandler
constructor
A new instance of TransactionHandler.
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_projector ⇒ Object
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 14 |
# File 'lib/mudrat_projector/transaction_handler.rb', line 9 def << transaction return defer(transaction) if transaction.date > @projection.range.end in_projection, leftover = transaction.slice @projection.range.end @projection.add_transaction_batch in_projection defer leftover if leftover end |
#defer(transaction) ⇒ Object
16 17 18 |
# File 'lib/mudrat_projector/transaction_handler.rb', line 16 def defer transaction next_projector.add_transaction transaction if next_projector end |