Class: OFlow::Link
- Inherits:
-
Object
- Object
- OFlow::Link
- Defined in:
- lib/oflow/link.rb
Overview
A Link is the data needed to link one Task with another so that when the ship() method is called the data can be delivered to the destination Task.
Instance Attribute Summary collapse
-
#flow_name ⇒ Object
readonly
Name of the target’s parent flow.
-
#op ⇒ Object
readonly
Operation to provide the target.
-
#target ⇒ Object
readonly
The actual target Task.
-
#target_name ⇒ Object
readonly
Name of the target.
Instance Method Summary collapse
-
#initialize(flow_name, target_name, op) ⇒ Link
constructor
Creates a new Link.
-
#ship(box) ⇒ Object
Delivers a package (Box) to the target.
-
#to_s ⇒ Object
(also: #inspect)
Returns a string representation of the Link.
Constructor Details
#initialize(flow_name, target_name, op) ⇒ Link
Creates a new Link. This is called from link() and route() methods on Tasks and Flows.
24 25 26 27 28 29 |
# File 'lib/oflow/link.rb', line 24 def initialize(flow_name, target_name, op) @target_name = target_name @flow_name = flow_name @op = op @target = nil end |
Instance Attribute Details
#flow_name ⇒ Object (readonly)
Name of the target’s parent flow.
11 12 13 |
# File 'lib/oflow/link.rb', line 11 def flow_name @flow_name end |
#op ⇒ Object (readonly)
Operation to provide the target.
13 14 15 |
# File 'lib/oflow/link.rb', line 13 def op @op end |
#target ⇒ Object (readonly)
The actual target Task.
15 16 17 |
# File 'lib/oflow/link.rb', line 15 def target @target end |
#target_name ⇒ Object (readonly)
Name of the target.
9 10 11 |
# File 'lib/oflow/link.rb', line 9 def target_name @target_name end |
Instance Method Details
#ship(box) ⇒ Object
Delivers a package (Box) to the target.
33 34 35 |
# File 'lib/oflow/link.rb', line 33 def ship(box) @target.receive(@op, box) end |
#to_s ⇒ Object Also known as: inspect
Returns a string representation of the Link.
38 39 40 41 42 43 44 |
# File 'lib/oflow/link.rb', line 38 def to_s() if @flow_name.nil? "Link{target_name: #{@target_name}, op: #{op}, target: #{@target}}" else "Link{target_name: #{@flow_name}:#{@target_name}, op: #{op}, target: #{@target}}" end end |