Class: AFMotion::HTTPResult

Inherits:
Object
  • Object
show all
Defined in:
lib/afmotion/http_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task, responseObject, error) ⇒ HTTPResult

Returns a new instance of HTTPResult.



5
6
7
8
9
# File 'lib/afmotion/http_result.rb', line 5

def initialize(task, responseObject, error)
  self.task = task
  self.object = responseObject
  self.error = error
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



3
4
5
# File 'lib/afmotion/http_result.rb', line 3

def error
  @error
end

#objectObject

Returns the value of attribute object.



3
4
5
# File 'lib/afmotion/http_result.rb', line 3

def object
  @object
end

#taskObject

Returns the value of attribute task.



3
4
5
# File 'lib/afmotion/http_result.rb', line 3

def task
  @task
end

Instance Method Details

#bodyObject



33
34
35
# File 'lib/afmotion/http_result.rb', line 33

def body
  self.object
end

#failure?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/afmotion/http_result.rb', line 15

def failure?
  !!error
end

#operationObject

include this for backwards compatibility (?)



20
21
22
23
# File 'lib/afmotion/http_result.rb', line 20

def operation
  puts "HTTPResult#operation is deprecated and returns a task, switch to using #task"
  task
end

#status_codeObject



25
26
27
28
29
30
31
# File 'lib/afmotion/http_result.rb', line 25

def status_code
  if self.task && self.task.response
    self.task.response.statusCode
  else
    nil
  end
end

#success?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/afmotion/http_result.rb', line 11

def success?
  !failure?
end