Module: OFlow::HasLinks
Overview
Adds support for Links. Used by Flow and Env.
Instance Method Summary (collapse)
-
- (Link) find_link(label)
Attempts to find the Link identified by the label.
-
- (Object) init_links
Sets up the links attribute.
-
- (Object) link(label, target, op)
Creates a Link identified by the label that has a target Task or Flow and operation.
-
- (Hash) links
Returns the Links.
-
- (Link) resolve_link(label)
Attempts to find and resolve the Link identified by the label.
-
- (Object) set_link_target(lnk)
Sets the target Task for a Link.
Instance Method Details
- (Link) find_link(label)
Attempts to find the Link identified by the label.
52 53 54 55 |
# File 'lib/oflow/haslinks.rb', line 52 def find_link(label) label = label.to_sym unless label.nil? @links[label] || @links[nil] end |
- (Object) init_links
Sets up the links attribute.
8 9 10 |
# File 'lib/oflow/haslinks.rb', line 8 def init_links() @links = {} end |
- (Object) link(label, target, op)
Creates a Link identified by the label that has a target Task or Flow and operation.
17 18 19 20 21 22 23 |
# File 'lib/oflow/haslinks.rb', line 17 def link(label, target, op) label = label.to_sym unless label.nil? op = op.to_sym unless op.nil? raise ConfigError.new("Link #{label} already exists.") unless @links[label].nil? label = label.to_sym unless label.nil? @links[label] = Link.new(target.to_sym, op) end |
- (Hash) links
Returns the Links.
59 60 61 |
# File 'lib/oflow/haslinks.rb', line 59 def links() @links end |
- (Link) resolve_link(label)
Attempts to find and resolve the Link identified by the label. Resolving a Link uses the target identifier to find the target Task and save that in the Link.
30 31 32 33 34 35 36 |
# File 'lib/oflow/haslinks.rb', line 30 def resolve_link(label) label = label.to_sym unless label.nil? lnk = @links[label] || @links[nil] return nil if lnk.nil? set_link_target(lnk) if lnk.target.nil? lnk end |
- (Object) set_link_target(lnk)
Sets the target Task for a Link.
40 41 42 43 44 45 46 47 |
# File 'lib/oflow/haslinks.rb', line 40 def set_link_target(lnk) if lnk.ingress task = find_task(lnk.target_name) else task = @flow.find_task(lnk.target_name) end lnk.instance_variable_set(:@target, task) end |