Class: Fog::AzureRM::AsyncResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/azurerm/async_response.rb

Overview

class for Async Response

Instance Method Summary collapse

Constructor Details

#initialize(model, promise, delete_extra_resource = false, post_method_execute = nil) ⇒ AsyncResponse

Returns a new instance of AsyncResponse.



5
6
7
8
9
10
# File 'lib/fog/azurerm/async_response.rb', line 5

def initialize(model, promise, delete_extra_resource = false, post_method_execute = nil)
  @fog_model = model
  @promise = promise
  @delete_extra_resource = delete_extra_resource
  @post_method_execute = post_method_execute
end

Instance Method Details

#fulfilled?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/fog/azurerm/async_response.rb', line 35

def fulfilled?
  @promise.fulfilled?
end

#pending?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/fog/azurerm/async_response.rb', line 31

def pending?
  @promise.pending?
end

#reasonObject



27
28
29
# File 'lib/fog/azurerm/async_response.rb', line 27

def reason
  @promise.reason
end

#rejected?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/fog/azurerm/async_response.rb', line 39

def rejected?
  @promise.rejected?
end

#stateObject



23
24
25
# File 'lib/fog/azurerm/async_response.rb', line 23

def state
  @promise.state
end

#valueObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/azurerm/async_response.rb', line 12

def value
  response = @promise.value.body
  @fog_model.merge_attributes(@fog_model.class.parse(response))
  @fog_model.delete_extra_resources if @delete_extra_resource
  # This code block will execute the method mentioned in post_method_execute after getting the response
  unless @post_method_execute.nil?
    @fog_model.public_send(@post_method_execute) if @fog_model.respond_to? @post_method_execute
  end
  @fog_model
end