Class: Rester::Client::Adapters::HttpAdapter::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/rester/client/adapters/http_adapter/connection.rb

Constant Summary collapse

DEFAULT_DATA_HEADERS =
{
  "Content-Type".freeze => "application/x-www-form-urlencoded".freeze
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, opts = {}) ⇒ Connection

Returns a new instance of Connection.



15
16
17
18
19
# File 'lib/rester/client/adapters/http_adapter/connection.rb', line 15

def initialize(url, opts={})
  @url = url.is_a?(String) ? URI(url) : url
  @url.path = @url.path[0..-2] if @url.path[-1] == '/'
  @timeout = opts[:timeout]
end

Instance Attribute Details

#timeoutObject (readonly)

Returns the value of attribute timeout.



13
14
15
# File 'lib/rester/client/adapters/http_adapter/connection.rb', line 13

def timeout
  @timeout
end

#urlObject (readonly)

Returns the value of attribute url.



12
13
14
# File 'lib/rester/client/adapters/http_adapter/connection.rb', line 12

def url
  @url
end

Instance Method Details

#request(verb, path, params = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/rester/client/adapters/http_adapter/connection.rb', line 21

def request(verb, path, params={})
  _request(
    verb,
    _path(path, params[:query]),
    _headers(verb, params[:headers]),
    params[:data]
  )
end