Class: EventSourcedRecord::Calculator
- Inherits:
-
Object
- Object
- EventSourcedRecord::Calculator
- Defined in:
- lib/event_sourced_record/calculator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(lookup) ⇒ Calculator
constructor
A new instance of Calculator.
- #run(options = {}) ⇒ Object
Constructor Details
#initialize(lookup) ⇒ Calculator
Returns a new instance of Calculator.
12 13 14 |
# File 'lib/event_sourced_record/calculator.rb', line 12 def initialize(lookup) @lookup = lookup end |
Class Method Details
.event_classes ⇒ Object
6 7 8 9 10 |
# File 'lib/event_sourced_record/calculator.rb', line 6 def self.event_classes @@event_symbols.map { |sym| Module.const_get(sym.to_s.singularize.camelize) } end |
.events(*event_symbols) ⇒ Object
2 3 4 |
# File 'lib/event_sourced_record/calculator.rb', line 2 def self.events(*event_symbols) @@event_symbols = event_symbols end |
Instance Method Details
#run(options = {}) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/event_sourced_record/calculator.rb', line 16 def run( = {}) instance_variable_set(projection_variable_name, find_or_build_record) sorted_events([:last_event_time]).each do |event| advance_event(event) end instance_variable_get projection_variable_name end |