Class: Zesty::Request
- Inherits:
-
Object
- Object
- Zesty::Request
- Defined in:
- lib/zesty/request.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request_method ⇒ Object
readonly
Returns the value of attribute request_method.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
- .delete(url, params: {}, headers: {}) ⇒ Object
- .get(url, params: nil, headers: {}) ⇒ Object
- .post(url, params: {}, headers: {}) ⇒ Object
- .post_form(url, params: {}, headers: {}) ⇒ Object
- .put(url, params: {}, headers: {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(request_method, url, params, headers) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
Constructor Details
#initialize(request_method, url, params, headers) ⇒ Request
Returns a new instance of Request.
28 29 30 31 32 33 |
# File 'lib/zesty/request.rb', line 28 def initialize(request_method, url, params, headers) @request_method = request_method @url = url @params = params @headers = headers end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/zesty/request.rb', line 6 def headers @headers end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/zesty/request.rb', line 6 def params @params end |
#request_method ⇒ Object (readonly)
Returns the value of attribute request_method.
6 7 8 |
# File 'lib/zesty/request.rb', line 6 def request_method @request_method end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/zesty/request.rb', line 6 def url @url end |
Class Method Details
.delete(url, params: {}, headers: {}) ⇒ Object
24 25 26 |
# File 'lib/zesty/request.rb', line 24 def self.delete(url, params: {}, headers: {}) Request.new(:delete, url, params, headers).perform end |
.get(url, params: nil, headers: {}) ⇒ Object
8 9 10 |
# File 'lib/zesty/request.rb', line 8 def self.get(url, params: nil, headers: {}) Request.new(:get, url, params, headers).perform end |
.post(url, params: {}, headers: {}) ⇒ Object
16 17 18 |
# File 'lib/zesty/request.rb', line 16 def self.post(url, params: {}, headers: {}) Request.new(:post, url, params, headers).perform end |
Instance Method Details
#perform ⇒ Object
35 36 37 38 |
# File 'lib/zesty/request.rb', line 35 def perform response = send(@request_method) process_response(response) end |