Sha256: 3ed57881ad1d2608c7e9d5504e8969f20fc2b5899776b5b0761978a2ea2d09d6

Contents?: true

Size: 786 Bytes

Versions: 10

Compression:

Stored size: 786 Bytes

Contents

module AFMotion
  class HTTPResult
    attr_accessor :operation, :object, :error, :task

    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

    def success?
      !failure?
    end

    def failure?
      !!error
    end

    def body
      if task && task.currentRequest
        raise "Cannot call result.body of a task"
      end
      if operation && operation.responseString
        operation.responseString
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
afmotion-2.3.1 lib/afmotion/http_result.rb
afmotion-2.2.0 lib/afmotion/http_result.rb
afmotion-2.1.5 lib/afmotion/http_result.rb
afmotion-2.1.4 lib/afmotion/http_result.rb
afmotion-2.1.3 lib/afmotion/http_result.rb
afmotion-2.1.2 lib/afmotion/http_result.rb
afmotion-2.1.1 lib/afmotion/http_result.rb
afmotion-2.1.0 lib/afmotion/http_result.rb
afmotion-2.0.0 lib/afmotion/http_result.rb
afmotion-2.0.0.rc2 lib/afmotion/http_result.rb