Module: Lieutenant::Aggregate::ClassMethods
- Defined in:
- lib/lieutenant/aggregate.rb
Overview
Define common class methods to aggregates
Instance Method Summary collapse
- #handlers_for(event_class) ⇒ Object
- #load_from_history(id, history) ⇒ Object
- #on(*event_classes, &handler) ⇒ Object
Instance Method Details
#handlers_for(event_class) ⇒ Object
26 27 28 |
# File 'lib/lieutenant/aggregate.rb', line 26 def handlers_for(event_class) handlers[event_class] end |
#load_from_history(id, history) ⇒ Object
12 13 14 |
# File 'lib/lieutenant/aggregate.rb', line 12 def load_from_history(id, history) allocate.send(:load_from_history, id, history) end |
#on(*event_classes, &handler) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/lieutenant/aggregate.rb', line 16 def on(*event_classes, &handler) event_classes.each do |event_class| unless event_class < Event raise(Lieutenant::Exception, "Expected #{event_class} to include Lieutenant::Event") end handlers[event_class] = handlers[event_class].push(handler) end end |