Method: Unipept::BatchOrder#wait

Defined in:
lib/batch_order.rb

#wait(i, &block) ⇒ Object

Executes block if it’s its turn, queues the block in the other case.



11
12
13
14
15
16
17
18
19
# File 'lib/batch_order.rb', line 11

def wait(i, &block)
  @order[i] = block
  return unless i == @current

  while order[@current]
    order.delete(@current).call
    @current += 1
  end
end