Class: AFMotion::Client

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.sharedObject

Returns the value of attribute shared


7
8
9
# File 'lib/afmotion/http_client.rb', line 7

def shared
  @shared
end

Class Method Details

.build(base_url, &block) ⇒ Object

Returns an instance of AFHTTPRequestOperationManager


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/afmotion/http_client.rb', line 10

def build(base_url, &block)
  operation_manager = AFHTTPRequestOperationManager.alloc.initWithBaseURL(base_url.to_url)
  if block
    dsl = AFMotion::ClientDSL.new(operation_manager)
    case block.arity
    when 0
      dsl.instance_eval(&block)
    when 1
      block.call(dsl)
    end
  end
  if !operation_manager.operationQueue
    operation_manager.operationQueue = NSOperationQueue.mainQueue
  end
  operation_manager
end

.build_shared(base_url, &block) ⇒ Object

Sets AFMotion::Client.shared as the built client


28
29
30
# File 'lib/afmotion/http_client.rb', line 28

def build_shared(base_url, &block)
  self.shared = self.build(base_url, &block)
end