class LittleGhost::Assembly::Trajectory
Immutable queries over the steps returned by one assembly invocation.
Attributes
Immutable steps in execution order.
Public Class Methods
Source
# File lib/little_ghost/assembly_execution.rb, line 133 def initialize(steps) @steps = Array(steps).freeze @by_id = @steps.to_h { |step| [step.id, step] }.freeze freeze end
Builds query indexes for steps.
Public Instance Methods
Source
# File lib/little_ghost/assembly_execution.rb, line 146 def attempts_for(id) = step(id)&.attempts || [].freeze
Returns attempts belonging to one step.
Source
# File lib/little_ghost/assembly_execution.rb, line 144 def children(id) = steps.select { |item| item.parent_id == id.to_s }.freeze
Returns steps whose parent is id.
# File lib/little_ghost/assembly_execution.rb, line 156 def concurrent?(first_id, second_id) first = step(first_id) second = step(second_id) return false unless first && second first.attempts.any? do |left| second.attempts.any? do |right| left.started_at < right.finished_at && right.started_at < left.finished_at end end end
Indicates whether attempts from two steps overlapped in time.
Source
# File lib/little_ghost/assembly_execution.rb, line 140 def each(&block) = steps.each(&block)
Iterates through steps in execution order.
Source
# File lib/little_ghost/assembly_execution.rb, line 142 def step(id) = @by_id[id.to_s]
Finds one step by its stable ID.
Source
# File lib/little_ghost/assembly_execution.rb, line 149 def transitions steps.flat_map do |item| item.predecessor_ids.map { |predecessor| [predecessor, item.id].freeze } end.freeze end
Returns declared predecessor-to-step ID pairs.