Class: Cleversafe::HttpClient

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

Constant Summary collapse

DEFAULTS =
{ :timeout => nil, :open_timeout => nil }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ HttpClient

Returns a new instance of HttpClient.



13
14
15
16
# File 'lib/cleversafe/http_client.rb', line 13

def initialize(url, options = {})
  @url = url
  @defaults = DEFAULTS.merge(options)
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



11
12
13
# File 'lib/cleversafe/http_client.rb', line 11

def url
  @url
end

Instance Method Details

#delete(path, options = {}) ⇒ Object



38
39
40
# File 'lib/cleversafe/http_client.rb', line 38

def delete(path, options = {})
  request :delete, path, options
end

#get(path, options = {}) ⇒ Object



26
27
28
# File 'lib/cleversafe/http_client.rb', line 26

def get(path, options = {})
  request :get, path, options
end

#head(path, options = {}) ⇒ Object



22
23
24
# File 'lib/cleversafe/http_client.rb', line 22

def head(path, options = {})
  request :head, path, options
end

#post(path, payload, options = {}) ⇒ Object



30
31
32
# File 'lib/cleversafe/http_client.rb', line 30

def post(path, payload, options = {})
  request :post, path, options.merge(:payload => payload)
end

#put(path, payload, options = {}) ⇒ Object



34
35
36
# File 'lib/cleversafe/http_client.rb', line 34

def put(path, payload, options = {})
  request :put, path, options.merge(:payload => payload)
end

#url_for(*path) ⇒ Object



18
19
20
# File 'lib/cleversafe/http_client.rb', line 18

def url_for(*path)
  File.join(url, *path)
end