Class: Pangea::Magma::Chain::Builder
- Defined in:
- lib/pangea/magma/chain.rb
Instance Attribute Summary collapse
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#workspaces ⇒ Object
readonly
Returns the value of attribute workspaces.
Instance Method Summary collapse
- #edge(from:, output:, to:, input:) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #workspace(ws) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
37 38 39 40 |
# File 'lib/pangea/magma/chain.rb', line 37 def initialize @workspaces = {} @edges = [] end |
Instance Attribute Details
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
36 37 38 |
# File 'lib/pangea/magma/chain.rb', line 36 def edges @edges end |
#workspaces ⇒ Object (readonly)
Returns the value of attribute workspaces.
36 37 38 |
# File 'lib/pangea/magma/chain.rb', line 36 def workspaces @workspaces end |
Instance Method Details
#edge(from:, output:, to:, input:) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pangea/magma/chain.rb', line 51 def edge(from:, output:, to:, input:) from_name = from.respond_to?(:name) ? from.name : from to_name = to.respond_to?(:name) ? to.name : to unless @workspaces.key?(from_name) raise ArgumentError, "edge.from references unknown workspace: #{from_name}" end unless @workspaces.key?(to_name) raise ArgumentError, "edge.to references unknown workspace: #{to_name}" end @edges << ChainEdge.new( from: from_name, from_output: output, to: to_name, to_input: input, ) self end |