module RestEasy
Constants
- VERSION
Public Instance Methods
get_until(uri, timeout = 10, opts = {}) { |resp| ... }
click to toggle source
Wait until an API call block resolves to true or the timeout is reached. The default is 10 seconds.
@param uri [String] API endpoint @param timeout [Fixnum] time to wait until false is returned @param opts [Hash] options yielded to block @param block [Proc] API call to evaluate
@return [Boolean]
# 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 = {}) { |resp| ... }
click to toggle source
Wait while an API call block resolves to true or the timeout is reached. The default is 10 seconds.
@param uri [String] API endpoint @param timeout [Fixnum] time to wait until false is returned @param opts [Hash] options yielded to block @param block [Proc] API call to evaluate
@return [Boolean]
# 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
Private Instance Methods
iterate(timeout) { |block until now > timed_out| ... }
click to toggle source
# File lib/rest_easy.rb, line 47 def iterate timeout, &block timed_out = Time.now + timeout yield block until Time.now > timed_out false end