Module: YuiRestClient::Wait

Defined in:
lib/yui_rest_client/wait.rb

Class Method Summary collapse

Class Method Details

.until(timeout:, interval:, message: nil, object: nil) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/yui_rest_client/wait.rb', line 5

def self.until(timeout:, interval:, message: nil, object: nil)
  Timer.wait(timeout, interval) do
    result = yield(object)
    return result if result
  end
  raise Error::TimeoutError, "timed out after #{timeout} seconds. #{message}"
end

.while(timeout:, interval:, message: nil, object: nil) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/yui_rest_client/wait.rb', line 13

def self.while(timeout:, interval:, message: nil, object: nil)
  Timer.wait(timeout, interval) do
    result = yield(object)
    return unless result
  end
  raise Error::TimeoutError, "timed out after #{timeout} seconds. #{message}"
end