Class: Motion::HTTP::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/common/http/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, url, headers = nil, params = nil, &callback) ⇒ Request

Returns a new instance of Request.



6
7
8
9
10
11
12
# File 'lib/common/http/request.rb', line 6

def initialize(method, url, headers = nil, params = nil, &callback)
  @method = method
  @url = url
  @headers = headers || Headers.new
  @body = params # TODO: turn params into body and set content-type?
  @callback = callback || ->(response) {}
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



4
5
6
# File 'lib/common/http/request.rb', line 4

def body
  @body
end

#callbackObject (readonly)

Returns the value of attribute callback.



4
5
6
# File 'lib/common/http/request.rb', line 4

def callback
  @callback
end

#headersObject (readonly)

Returns the value of attribute headers.



4
5
6
# File 'lib/common/http/request.rb', line 4

def headers
  @headers
end

#methodObject (readonly)

Returns the value of attribute method.



4
5
6
# File 'lib/common/http/request.rb', line 4

def method
  @method
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/common/http/request.rb', line 4

def url
  @url
end

Instance Method Details

#callObject



14
15
16
17
# File 'lib/common/http/request.rb', line 14

def call
  # TODO: maybe pass self instead of args
  Adapter.request(method, url, headers, body, &callback)
end