Class: Cleversafe::HttpClient
- Inherits:
-
Object
- Object
- Cleversafe::HttpClient
- Defined in:
- lib/cleversafe/http_client.rb
Constant Summary collapse
- DEFAULTS =
{ :timeout => nil, :open_timeout => nil }
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #delete(path, options = {}) ⇒ Object
- #get(path, options = {}) ⇒ Object
- #head(path, options = {}) ⇒ Object
-
#initialize(url, options = {}) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #post(path, payload, options = {}) ⇒ Object
- #put(path, payload, options = {}) ⇒ Object
- #url_for(*path) ⇒ Object
Constructor Details
#initialize(url, options = {}) ⇒ HttpClient
7 8 9 10 |
# File 'lib/cleversafe/http_client.rb', line 7 def initialize(url, = {}) @url = url @defaults = DEFAULTS.merge() end |
Instance Attribute Details
#url ⇒ Object (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, = {}) request :delete, path, end |
#get(path, options = {}) ⇒ Object
20 21 22 |
# File 'lib/cleversafe/http_client.rb', line 20 def get(path, = {}) request :get, path, end |
#head(path, options = {}) ⇒ Object
16 17 18 |
# File 'lib/cleversafe/http_client.rb', line 16 def head(path, = {}) request :head, path, end |
#post(path, payload, options = {}) ⇒ Object
24 25 26 |
# File 'lib/cleversafe/http_client.rb', line 24 def post(path, payload, = {}) request :post, path, .merge(:payload => payload) end |
#put(path, payload, options = {}) ⇒ Object
28 29 30 |
# File 'lib/cleversafe/http_client.rb', line 28 def put(path, payload, = {}) request :put, path, .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 |