Module: RestEasy
Constant Summary collapse
- VERSION =
"1.0.1"
Instance Method Summary collapse
-
#get_until(uri, timeout = 10, opts = {}, &block) ⇒ Boolean
Wait until an API call block resolves to true or the timeout is reached.
-
#get_while(uri, timeout = 10, opts = {}, &block) ⇒ Boolean
Wait while an API call block resolves to true or the timeout is reached.
Instance Method Details
#get_until(uri, timeout = 10, opts = {}, &block) ⇒ Boolean
Wait until an API call block resolves to true or the timeout is reached. The default is 10 seconds.
18 19 20 21 22 23 24 |
# File 'lib/rest_easy.rb', line 18 def get_until uri, timeout = 10, opts = {}, &block iterate timeout do result = RestClient.get(uri, opts){ |resp| yield resp } return true if result sleep 0.5 end end |
#get_while(uri, timeout = 10, opts = {}, &block) ⇒ Boolean
Wait while an API call block resolves to true or the timeout is reached. The default is 10 seconds.
37 38 39 40 41 42 43 |
# File 'lib/rest_easy.rb', line 37 def get_while uri, timeout = 10, opts = {}, &block iterate timeout do result = RestClient.get(uri, opts){ |resp| yield resp } return true unless result sleep 0.5 end end |