26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/winker/devices/device_methods.rb', line 26
def wait_for_update(boolean_proc, options = {}, &block)
if Winker.wait_for_updates
options = {
timeout: WAIT_BLOCK_TIMEOUT
}.merge(options)
start = Time.now
until (success = boolean_proc.call) || Time.now > start+options[:timeout]
result = yield
sleep WAIT_BLOCK_SLEEP
end
if success
return result
else
raise "Device #{self.type} #{self.name} not updated and timed out after #{options[:timeout]}."
end
end
end
|