Class: Powcloud::Insurance::Channel::ProcChain

Inherits:
Object
  • Object
show all
Defined in:
lib/powcloud/insurance/channel.rb

Overview

Collection of procs, which could be called one by one asynchronously. Each proc should call next() on ProcChain instance.

Instance Method Summary collapse

Constructor Details

#initializeProcChain

Returns a new instance of ProcChain.



7
8
9
# File 'lib/powcloud/insurance/channel.rb', line 7

def initialize
  @collection = []
end

Instance Method Details

#<<(blk) ⇒ Object



16
17
18
# File 'lib/powcloud/insurance/channel.rb', line 16

def <<(blk)
  @collection << blk
end

#callObject



20
21
22
# File 'lib/powcloud/insurance/channel.rb', line 20

def call
  self.next
end

#nextObject



11
12
13
14
# File 'lib/powcloud/insurance/channel.rb', line 11

def next
  next_proc = @collection.shift
  next_proc.call if next_proc
end