Class: Openlab::Projects
- Inherits:
-
Object
- Object
- Openlab::Projects
- Defined in:
- lib/openlab/projects.rb
Constant Summary collapse
- PROJECTS_PATH =
'/projects'
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #create(attributes) ⇒ Object
- #destroy(id) ⇒ Object
-
#initialize(client = nil) ⇒ Projects
constructor
A new instance of Projects.
- #search(q, opts = {}) ⇒ Object
- #update(id, attributes) ⇒ Object
Constructor Details
#initialize(client = nil) ⇒ Projects
Returns a new instance of Projects.
7 8 9 |
# File 'lib/openlab/projects.rb', line 7 def initialize(client = nil) @client = client || Openlab::Client.new end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/openlab/projects.rb', line 5 def client @client end |
Instance Method Details
#create(attributes) ⇒ Object
15 16 17 |
# File 'lib/openlab/projects.rb', line 15 def create(attributes) client.post(path, body: { project: attributes }) end |
#destroy(id) ⇒ Object
23 24 25 |
# File 'lib/openlab/projects.rb', line 23 def destroy(id) client.delete("#{path}/#{id}") end |
#search(q, opts = {}) ⇒ Object
11 12 13 |
# File 'lib/openlab/projects.rb', line 11 def search(q, opts = {}) client.get(path, query: { q: q }.merge(opts)) end |
#update(id, attributes) ⇒ Object
19 20 21 |
# File 'lib/openlab/projects.rb', line 19 def update(id, attributes) client.patch("#{path}/#{id}", body: { project: attributes }) end |