module WaitFor extend self def wait_for(time=5) Timeout.timeout(time) do loop do value = yield return value if value end end end end