Class: Cumuli::Waiter
- Inherits:
-
Object
- Object
- Cumuli::Waiter
- Defined in:
- lib/cumuli/waiter.rb
Constant Summary collapse
- TIMEOUT =
30
- MESSAGE =
"#wait_until did not resolve after #{TIMEOUT} seconds"
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(message = MESSAGE) ⇒ Waiter
constructor
A new instance of Waiter.
- #wait_until(timeout = TIMEOUT, &block) ⇒ Object
Constructor Details
#initialize(message = MESSAGE) ⇒ Waiter
Returns a new instance of Waiter.
8 9 10 |
# File 'lib/cumuli/waiter.rb', line 8 def initialize(=MESSAGE) @message = end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/cumuli/waiter.rb', line 6 def @message end |
Instance Method Details
#wait_until(timeout = TIMEOUT, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cumuli/waiter.rb', line 12 def wait_until(timeout=TIMEOUT, &block) begin Timeout.timeout(timeout) do sleep(0.1) until value = block.call value end rescue Timeout::Error raise end end |