Class: Spinoza::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/spinoza/system/timeline.rb

Overview

Events are the way we model the passage of time in a concurrent system. An event action initiates some action at some time. The action happens instantaneously on the timeline, except by scheduling later events.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time: raise, actor: raise, action: raise, **data) ⇒ Event

Returns a new instance of Event.



12
13
14
# File 'lib/spinoza/system/timeline.rb', line 12

def initialize time: raise, actor: raise, action: raise, **data
  @time, @actor, @action, @data = time, actor, action, data
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



8
9
10
# File 'lib/spinoza/system/timeline.rb', line 8

def action
  @action
end

#actorObject (readonly)

Returns the value of attribute actor.



8
9
10
# File 'lib/spinoza/system/timeline.rb', line 8

def actor
  @actor
end

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/spinoza/system/timeline.rb', line 8

def data
  @data
end

#timeObject (readonly)

Returns the value of attribute time.



8
9
10
# File 'lib/spinoza/system/timeline.rb', line 8

def time
  @time
end

Instance Method Details

#dispatchObject



16
17
18
19
20
21
22
# File 'lib/spinoza/system/timeline.rb', line 16

def dispatch
  if data.empty?
    actor.send action
  else
    actor.send action, **data
  end
end