Class: Tenk::Projects::ProjectResource
- Inherits:
-
Object
- Object
- Tenk::Projects::ProjectResource
- Defined in:
- lib/projects/project_resource.rb
Overview
A base class for subresources under a project (within a /projects/:id url space)
Direct Known Subclasses
Instance Method Summary collapse
-
#create(project_id, options) ⇒ Hashie::Mash
The default implementation of create requests for project subresources.
-
#delete(project_id, id) ⇒ Hashie::Mash
The default implementation of delete requests for project subresources.
-
#get(project_id, id, options) ⇒ Hashie::Mash
The default implementation of get requests for project subresources.
-
#initialize(client) ⇒ ProjectResource
constructor
A new instance of ProjectResource.
-
#list(project_id, options) ⇒ Hashie::Mash
The default implementation of list requests for project subresources.
-
#resource_root(project_id) ⇒ String
The base route for subresources under this project By default, infers this URL from the resource class name.
-
#update(project_id, id, options) ⇒ Hashie::Mash
The default implementation of update requests for project subresources.
Constructor Details
#initialize(client) ⇒ ProjectResource
Returns a new instance of ProjectResource.
9 10 11 |
# File 'lib/projects/project_resource.rb', line 9 def initialize(client) @_client = client end |
Instance Method Details
#create(project_id, options) ⇒ Hashie::Mash
The default implementation of create requests for project subresources
35 36 37 |
# File 'lib/projects/project_resource.rb', line 35 def create(project_id, ) @_client.post(resource_root(project_id), ) end |
#delete(project_id, id) ⇒ Hashie::Mash
The default implementation of delete requests for project subresources
47 48 49 |
# File 'lib/projects/project_resource.rb', line 47 def delete(project_id, id) @_client.delete("#{resource_root(project_id)}/#{id}") end |
#get(project_id, id, options) ⇒ Hashie::Mash
The default implementation of get requests for project subresources
29 30 31 |
# File 'lib/projects/project_resource.rb', line 29 def get(project_id, id, ) @_client.get("#{resource_root(project_id)}/#{id}", ) end |
#list(project_id, options) ⇒ Hashie::Mash
The default implementation of list requests for project subresources
23 24 25 |
# File 'lib/projects/project_resource.rb', line 23 def list(project_id, ) @_client.get(resource_root(project_id), ) end |
#resource_root(project_id) ⇒ String
The base route for subresources under this project By default, infers this URL from the resource class name
17 18 19 |
# File 'lib/projects/project_resource.rb', line 17 def resource_root(project_id) "/projects/#{project_id}/#{self.class.name.demodulize.tableize}" end |
#update(project_id, id, options) ⇒ Hashie::Mash
The default implementation of update requests for project subresources
41 42 43 |
# File 'lib/projects/project_resource.rb', line 41 def update(project_id, id, ) @_client.put("#{resource_root(project_id)}/#{id}", ) end |