Class: Trailblazer::Developer::Introspect::Graph

Inherits:
Object
  • Object
show all
Defined in:
lib/trailblazer/developer/introspect/graph.rb

Overview

TODO: Remove Graph. This is only useful to render the full circuit Some thoughts here:

  • where do we need Schema.outputs? and where task.outputs?

Defined Under Namespace

Classes: Node, Outgoing

Instance Method Summary collapse

Constructor Details

#initialize(activity) ⇒ Graph

Returns a new instance of Graph.



14
15
16
17
18
19
# File 'lib/trailblazer/developer/introspect/graph.rb', line 14

def initialize(activity)
  @schema   = activity.to_h or raise
  @circuit  = @schema[:circuit]
  @map      = @circuit.to_h[:map]
  @configs  = @schema[:nodes]
end

Instance Method Details

#collect(strategy: :circuit) ⇒ Object

TODO: convert to #to_a.



28
29
30
# File 'lib/trailblazer/developer/introspect/graph.rb', line 28

def collect(strategy: :circuit)
  @map.keys.each_with_index.collect { |task, i| yield find_with_block { |node| node.task == task }, i }
end

#find(id = nil, &block) ⇒ Object



21
22
23
24
25
# File 'lib/trailblazer/developer/introspect/graph.rb', line 21

def find(id = nil, &block)
  return find_by_id(id) unless block_given?

  find_with_block(&block)
end

#stop_eventsObject



32
33
34
# File 'lib/trailblazer/developer/introspect/graph.rb', line 32

def stop_events
  @circuit.to_h[:end_events]
end