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



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

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

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/cleversafe/http_client.rb', line 5

def url
  @url
end

Instance Method Details

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



32
33
34
# File 'lib/cleversafe/http_client.rb', line 32

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

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



20
21
22
# File 'lib/cleversafe/http_client.rb', line 20

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

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



16
17
18
# File 'lib/cleversafe/http_client.rb', line 16

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

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



24
25
26
# File 'lib/cleversafe/http_client.rb', line 24

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

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



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

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

#url_for(*path) ⇒ Object



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

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