Class: AFMotion::HTTPResult
- Inherits:
-
Object
- Object
- AFMotion::HTTPResult
- Defined in:
- lib/afmotion/http_result.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#object ⇒ Object
Returns the value of attribute object.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#task ⇒ Object
Returns the value of attribute task.
Instance Method Summary collapse
- #body ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(operation_or_task, responseObject, error) ⇒ HTTPResult
constructor
A new instance of HTTPResult.
- #status_code ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(operation_or_task, responseObject, error) ⇒ HTTPResult
Returns a new instance of HTTPResult.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/afmotion/http_result.rb', line 5 def initialize(operation_or_task, responseObject, error) if defined?(NSURLSessionTask) && operation_or_task.is_a?(NSURLSessionTask) || # cluser class ugh operation_or_task.class.to_s.include?("Task") self.task = operation_or_task else self.operation = operation_or_task end self.object = responseObject self.error = error end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
3 4 5 |
# File 'lib/afmotion/http_result.rb', line 3 def error @error end |
#object ⇒ Object
Returns the value of attribute object.
3 4 5 |
# File 'lib/afmotion/http_result.rb', line 3 def object @object end |
#operation ⇒ Object
Returns the value of attribute operation.
3 4 5 |
# File 'lib/afmotion/http_result.rb', line 3 def operation @operation end |
#task ⇒ Object
Returns the value of attribute task.
3 4 5 |
# File 'lib/afmotion/http_result.rb', line 3 def task @task end |
Instance Method Details
#body ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/afmotion/http_result.rb', line 33 def body if task && task.currentRequest raise "Cannot call result.body of a task" end if operation && operation.responseString operation.responseString end end |
#failure? ⇒ Boolean
21 22 23 |
# File 'lib/afmotion/http_result.rb', line 21 def failure? !!error end |
#status_code ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/afmotion/http_result.rb', line 25 def status_code if self.operation self.operation.response.statusCode else self.task.response.statusCode end end |
#success? ⇒ Boolean
17 18 19 |
# File 'lib/afmotion/http_result.rb', line 17 def success? !failure? end |