module Waiter

The waiter waits.

Constants

DEFAULT_TIMEOUT
POLL_SLEEP_TIME

Public Instance Methods

await(lamb, timeout = DEFAULT_TIMEOUT, poll_sleep_time = POLL_SLEEP_TIME) click to toggle source

The lambda passed to await should return false if thing not found and something truthy if found

# File lib/utilities/waiter.rb, line 12
def await(lamb, timeout = DEFAULT_TIMEOUT, poll_sleep_time = POLL_SLEEP_TIME)
  Timeout.timeout(timeout) do
    loop do
      result = lamb.call
      return result if result
      # rubocop:disable Style/SleepCop
      sleep poll_sleep_time
      # rubocop:enable Style/SleepCop
    end
  end
end