Top Level Namespace

Defined Under Namespace

Modules: Soon

Instance Method Summary collapse

Instance Method Details

#soon(duration = 1, interval: 0.1, &block) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
# File 'lib/soon.rb', line 1

def soon(duration=1, interval: 0.1, &block)
  retry_until = Time.now + duration

  begin
    block.call
  rescue Exception => ex
    raise ex if Time.now >= retry_until

    sleep interval
    retry
  end
end