Class: Wukong::Driver
- Inherits:
-
Object
- Object
- Wukong::Driver
- Defined in:
- lib/wukong/driver.rb
Instance Attribute Summary collapse
-
#dataflow ⇒ Object
Returns the value of attribute dataflow.
Instance Method Summary collapse
- #advance(stage) ⇒ Object
- #call(*args) ⇒ Object
-
#initialize(dataflow) ⇒ Driver
constructor
A new instance of Driver.
- #send_through_dataflow(record) ⇒ Object
-
#stage_iterator(stage) ⇒ Object
This should properly be defined on dataflow/builder.
- #start_with(stage) ⇒ Object
- #to_proc ⇒ Object
Constructor Details
#initialize(dataflow) ⇒ Driver
Returns a new instance of Driver.
68 69 70 |
# File 'lib/wukong/driver.rb', line 68 def initialize(dataflow) @dataflow = dataflow end |
Instance Attribute Details
#dataflow ⇒ Object
Returns the value of attribute dataflow.
66 67 68 |
# File 'lib/wukong/driver.rb', line 66 def dataflow @dataflow end |
Instance Method Details
#advance(stage) ⇒ Object
87 88 89 90 |
# File 'lib/wukong/driver.rb', line 87 def advance(stage) next_stage = stage_iterator(stage) start_with(next_stage) end |
#call(*args) ⇒ Object
98 99 100 |
# File 'lib/wukong/driver.rb', line 98 def call(*args) to_proc.call(*args) end |
#send_through_dataflow(record) ⇒ Object
79 80 81 |
# File 'lib/wukong/driver.rb', line 79 def send_through_dataflow(record) start_with(dataflow.first).call(record) end |
#stage_iterator(stage) ⇒ Object
This should properly be defined on dataflow/builder
93 94 95 96 |
# File 'lib/wukong/driver.rb', line 93 def stage_iterator(stage) position = dataflow.find_index(stage) dataflow[position + 1] end |
#start_with(stage) ⇒ Object
83 84 85 |
# File 'lib/wukong/driver.rb', line 83 def start_with(stage) to_proc.curry.call(stage) end |
#to_proc ⇒ Object
72 73 74 75 76 77 |
# File 'lib/wukong/driver.rb', line 72 def to_proc return @wiring if @wiring @wiring = Proc.new do |stage, record| stage.process(record, &advance(stage)) if stage end end |