Class: Tenk::Resource
- Inherits:
-
Object
- Object
- Tenk::Resource
- Defined in:
- lib/resource.rb
Overview
The base class for all API resources
Direct Known Subclasses
Approvals, BillRates, PlaceholderResources, Projects, TimeEntries, Users
Instance Method Summary collapse
-
#create(options) ⇒ Object
The base method for create requests on all resources.
-
#get(id, options) ⇒ Object
The base method for get requests on all resources.
-
#initialize(client) ⇒ Resource
constructor
Initialize a base API resource from the client.
-
#list(options) ⇒ Object
The base method for list requests on all resources.
-
#resource_root ⇒ String
The root for this resource.
-
#update(id, options) ⇒ Object
The base method for update requests on all resources.
Constructor Details
#initialize(client) ⇒ Resource
Initialize a base API resource from the client
9 10 11 |
# File 'lib/resource.rb', line 9 def initialize(client) @_client = client end |
Instance Method Details
#create(options) ⇒ Object
The base method for create requests on all resources
30 31 32 |
# File 'lib/resource.rb', line 30 def create() @_client.post(resource_root, ) end |
#get(id, options) ⇒ Object
The base method for get requests on all resources
25 26 27 |
# File 'lib/resource.rb', line 25 def get(id, ) @_client.get("#{resource_root}/#{id}", ) end |
#list(options) ⇒ Object
The base method for list requests on all resources
20 21 22 |
# File 'lib/resource.rb', line 20 def list() @_client.get(resource_root, ) end |
#resource_root ⇒ String
The root for this resource. Default is based on class name tableized
15 16 17 |
# File 'lib/resource.rb', line 15 def resource_root "/#{self.class.name.demodulize.tableize}" end |
#update(id, options) ⇒ Object
The base method for update requests on all resources
35 36 37 |
# File 'lib/resource.rb', line 35 def update(id, ) @_client.put("#{resource_root}/#{id}", ) end |