Class: Hyperpublic::Request
- Inherits:
-
Object
- Object
- Hyperpublic::Request
- Extended by:
- Forwardable
- Defined in:
- lib/hyperpublic/request.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
- .delete(client, path, options = {}) ⇒ Object
- .get(client, path, options = {}) ⇒ Object
- .post(client, path, options = {}) ⇒ Object
- .post_multi(client, path, options = {}) ⇒ Object
- .put(client, path, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(client, method, path, options = {}) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(client, method, path, options = {}) ⇒ Request
Returns a new instance of Request.
29 30 31 |
# File 'lib/hyperpublic/request.rb', line 29 def initialize(client, method, path, ={}) @client, @method, @path, @options = client, method, path, end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
25 26 27 |
# File 'lib/hyperpublic/request.rb', line 25 def client @client end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
25 26 27 |
# File 'lib/hyperpublic/request.rb', line 25 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
25 26 27 |
# File 'lib/hyperpublic/request.rb', line 25 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
25 26 27 |
# File 'lib/hyperpublic/request.rb', line 25 def path @path end |
Class Method Details
.delete(client, path, options = {}) ⇒ Object
21 22 23 |
# File 'lib/hyperpublic/request.rb', line 21 def self.delete(client, path, ={}) new(client, :delete, path, ).perform end |
.get(client, path, options = {}) ⇒ Object
5 6 7 |
# File 'lib/hyperpublic/request.rb', line 5 def self.get(client, path, ={}) new(client, :get, path, ).perform end |
.post(client, path, options = {}) ⇒ Object
9 10 11 |
# File 'lib/hyperpublic/request.rb', line 9 def self.post(client, path, ={}) new(client, :post, path, ).perform end |
.post_multi(client, path, options = {}) ⇒ Object
13 14 15 |
# File 'lib/hyperpublic/request.rb', line 13 def self.post_multi(client, path, ={}) new(client, :post_multi, path, ).perform end |
.put(client, path, options = {}) ⇒ Object
17 18 19 |
# File 'lib/hyperpublic/request.rb', line 17 def self.put(client, path, ={}) new(client, :put, path, ).perform end |
Instance Method Details
#perform ⇒ Object
45 46 47 |
# File 'lib/hyperpublic/request.rb', line 45 def perform Hyperpublic.make_friendly(send("perform_#{method}")) end |
#uri ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hyperpublic/request.rb', line 33 def uri @uri ||= begin uri = URI.parse(path) if [:query] && [:query] != {} uri.query = to_query([:query]) end uri.to_s end end |