class OvirtSDK4::Future

Instances of this class are returned for operatoins that specify the `wait: false` parameter.

Public Class Methods

new(service, request, &block) click to toggle source

Creates a new future result.

@param service [Service] The service that created this future. @param request [HttpRequest] The request that this future will wait for when the `wait` method is called. @param block [Block] The block that will be executed to check the response, and to convert its body into the

right type of object.

@api private

# File lib/ovirtsdk4/service.rb, line 32
def initialize(service, request, &block)
  @service = service
  @request = request
  @block = block
end

Public Instance Methods

inspect() click to toggle source

Returns a string representation of the future.

@return [String] The string representation.

# File lib/ovirtsdk4/service.rb, line 55
def inspect
  "#<#{self.class.name}:#{@request.method} #{@request.url}>"
end
to_s() click to toggle source

Returns a string representation of the future.

@return [String] The string representation.

# File lib/ovirtsdk4/service.rb, line 64
def to_s
  inspect
end
wait() click to toggle source

Waits till the result of the operation that created this future is available.

@return [Object] The result of the operation that created this future.

# File lib/ovirtsdk4/service.rb, line 43
def wait
  response = @service.connection.wait(@request)
  raise response if response.is_a?(Exception)

  @block.call(response)
end