Class: Organizer::Request
- Inherits:
-
Object
- Object
- Organizer::Request
- Defined in:
- lib/organizer/request.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#query ⇒ Object
Returns the value of attribute query.
Instance Method Summary collapse
- #delete ⇒ Object
- #get ⇒ Object
-
#initialize(path = "", query = {}) ⇒ Request
constructor
A new instance of Request.
- #method_missing(method, *args) ⇒ Object
- #post ⇒ Object
- #put ⇒ Object
Constructor Details
#initialize(path = "", query = {}) ⇒ Request
Returns a new instance of Request.
5 6 7 8 |
# File 'lib/organizer/request.rb', line 5 def initialize(path = "", query = {}) @path = path @query = query end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/organizer/request.rb', line 3 def path @path end |
#query ⇒ Object
Returns the value of attribute query.
3 4 5 |
# File 'lib/organizer/request.rb', line 3 def query @query end |
Instance Method Details
#delete ⇒ Object
31 32 33 34 |
# File 'lib/organizer/request.rb', line 31 def delete response = api.delete(path, query).body Response.new(response) end |
#get ⇒ Object
10 11 12 13 |
# File 'lib/organizer/request.rb', line 10 def get response = api.get(path, query).body Response.new(response) end |
#post ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/organizer/request.rb', line 15 def post api.post do |req| req.url path req.headers['Content-Type'] = 'application/json' req.body = query.to_json end end |
#put ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/organizer/request.rb', line 23 def put api.put do |req| req.url path req.headers['Content-Type'] = 'application/json' req.body = query.to_json end end |