Class: Strutta::APIObject Abstract
- Inherits:
-
Object
- Object
- Strutta::APIObject
- Defined in:
- lib/strutta-api/api_object.rb
Overview
APIObject contains all the HTTP request methods
Direct Known Subclasses
Entries, Flow, Judging, Moderation, Participants, Points, Rounds
Instance Attribute Summary collapse
-
#game ⇒ Object
Returns the value of attribute game.
Instance Method Summary collapse
-
#all(params = {}) ⇒ Hash
GET index request (Uses instance vars of child object to generate resource path).
-
#create(params = {}) ⇒ Hash
POST request (Uses instance vars of child object to generate resource path).
-
#delete ⇒ Hash
DELETE request (Uses instance vars of child object to generate resource path).
-
#get(params = {}) ⇒ Hash
GET request (Uses instance vars of child object to generate resource path).
-
#method_disabled(*_) ⇒ Object
Manually disable a method in child classed.
-
#update(params = {}) ⇒ Hash
PATCH request (Uses instance vars of child object to generate resource path).
Instance Attribute Details
permalink #game ⇒ Object
Returns the value of attribute game.
6 7 8 |
# File 'lib/strutta-api/api_object.rb', line 6 def game @game end |
Instance Method Details
permalink #all(params = {}) ⇒ Hash
GET index request (Uses instance vars of child object to generate resource path)
12 13 14 15 |
# File 'lib/strutta-api/api_object.rb', line 12 def all(params = {}) @game.verify_no_id(@id) @game.all(params, "#{@game.id}/#{@root_path}") end |
permalink #create(params = {}) ⇒ Hash
POST request (Uses instance vars of child object to generate resource path)
21 22 23 24 |
# File 'lib/strutta-api/api_object.rb', line 21 def create(params = {}) @game.verify_no_id(@id) @game.create(params, "#{@game.id}/#{@root_path}") end |
permalink #delete ⇒ Hash
DELETE request (Uses instance vars of child object to generate resource path)
48 49 50 51 |
# File 'lib/strutta-api/api_object.rb', line 48 def delete @game.verify_id(@id, Errors::ROUND_ID_REQUIRED) @game.delete(@root_path) end |
permalink #get(params = {}) ⇒ Hash
GET request (Uses instance vars of child object to generate resource path)
30 31 32 33 |
# File 'lib/strutta-api/api_object.rb', line 30 def get(params = {}) @game.verify_id(@id, Errors::ROUND_ID_REQUIRED) @game.get(params, @root_path) end |
permalink #method_disabled(*_) ⇒ Object
Manually disable a method in child classed
54 55 56 |
# File 'lib/strutta-api/api_object.rb', line 54 def method_disabled(*_) fail Errors::DisabledEndpointError, Errors::METHOD_DISABLED end |
permalink #update(params = {}) ⇒ Hash
PATCH request (Uses instance vars of child object to generate resource path)
39 40 41 42 |
# File 'lib/strutta-api/api_object.rb', line 39 def update(params = {}) @game.verify_id(@id, Errors::ROUND_ID_REQUIRED) @game.update(params, @root_path) end |