Class: Dynflow::ExecutionHistory
- Inherits:
-
Object
- Object
- Dynflow::ExecutionHistory
- Includes:
- Algebrick::TypeCheck, Enumerable
- Defined in:
- lib/dynflow/execution_history.rb
Defined Under Namespace
Modules: Event
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Class Method Summary collapse
Instance Method Summary collapse
- #add(name, world_id = nil) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(events = []) ⇒ ExecutionHistory
constructor
A new instance of ExecutionHistory.
- #inspect ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(events = []) ⇒ ExecutionHistory
Returns a new instance of ExecutionHistory.
21 22 23 |
# File 'lib/dynflow/execution_history.rb', line 21 def initialize(events = []) @events = (events || []).each { |e| Type! e, Event } end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
19 20 21 |
# File 'lib/dynflow/execution_history.rb', line 19 def events @events end |
Class Method Details
.new_from_hash(value) ⇒ Object
41 42 43 44 45 |
# File 'lib/dynflow/execution_history.rb', line 41 def self.new_from_hash(value) value ||= [] # for compatibility with tasks before the # introduction of execution history self.new(value.map { |hash| Event[hash] }) end |
Instance Method Details
#add(name, world_id = nil) ⇒ Object
29 30 31 |
# File 'lib/dynflow/execution_history.rb', line 29 def add(name, world_id = nil) @events << Event[Time.now.to_i, name, world_id] end |
#each(&block) ⇒ Object
25 26 27 |
# File 'lib/dynflow/execution_history.rb', line 25 def each(&block) @events.each(&block) end |
#inspect ⇒ Object
37 38 39 |
# File 'lib/dynflow/execution_history.rb', line 37 def inspect "ExecutionHistory: #{ @events.inspect }" end |
#to_hash ⇒ Object
33 34 35 |
# File 'lib/dynflow/execution_history.rb', line 33 def to_hash @events.map(&:to_hash) end |