Module: Jouba::Aggregate::InstanceMethods
- Defined in:
- lib/jouba/aggregate.rb
Instance Method Summary collapse
- #emit(name, *args) ⇒ Object
- #replay(event) ⇒ Object (also: #apply_event)
- #to_key ⇒ Object
Instance Method Details
#emit(name, *args) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/jouba/aggregate.rb', line 28 def emit(name, *args) Jouba.emit(to_key, name, args) do |event| apply_event(event) Jouba.Cache.refresh(to_key, self) { event.track } publish(event.name, event.data) end end |
#replay(event) ⇒ Object Also known as: apply_event
36 37 38 |
# File 'lib/jouba/aggregate.rb', line 36 def replay(event) send __callback_method__(:"#{event.name}"), *event.data end |
#to_key ⇒ Object
41 42 43 44 |
# File 'lib/jouba/aggregate.rb', line 41 def to_key fail 'Please make sure there is a uuid first' unless respond_to?(:uuid) && !uuid.nil? self.class.key_from_uuid(uuid) end |