Class: Contrails::Serial
- Inherits:
-
Object
- Object
- Contrails::Serial
- Includes:
- Chainable
- Defined in:
- lib/contrails/serial.rb
Instance Method Summary collapse
- #bind(other) ⇒ Object
- #call(*args) ⇒ Object
-
#initialize(*procs) ⇒ Serial
constructor
A new instance of Serial.
Methods included from Chainable
#*, #>>, #distribute, included, #run, #to_proc
Constructor Details
#initialize(*procs) ⇒ Serial
Returns a new instance of Serial.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/contrails/serial.rb', line 5 def initialize(*procs) @procs = procs @procs_with_callbacks = @procs.map {|p| p && p.dup} @procs_with_callbacks.zip(@procs_with_callbacks[1..-1]).each do |proc1, proc2| if proc2 proc1.callback {|*args| proc2.call(*args) } else proc1.callback {|*args| self.succeed(*args)} end end end |