Class: Refocus::Subjects
- Inherits:
-
Object
- Object
- Refocus::Subjects
- Includes:
- JsonHelper, PathHelper
- Defined in:
- lib/refocus/subjects.rb
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
Instance Method Summary collapse
- #all ⇒ Object
- #create(name:, options: {}) ⇒ Object
- #delete(name:) ⇒ Object
- #get(name:) ⇒ Object
-
#initialize(url:, token:) ⇒ Subjects
constructor
A new instance of Subjects.
- #update(name:, options:) ⇒ Object
Methods included from PathHelper
Methods included from JsonHelper
Constructor Details
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
10 11 12 |
# File 'lib/refocus/subjects.rb', line 10 def http @http end |
Instance Method Details
#all ⇒ Object
16 17 18 |
# File 'lib/refocus/subjects.rb', line 16 def all json(http.get("")) end |
#create(name:, options: {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/refocus/subjects.rb', line 20 def create(name:, options: {}) parent, child = parent_and_name(name) path = parent ? "#{parent}/child" : "" body = .merge({"name" => child}) json(http.post(path, body: body)) end |
#delete(name:) ⇒ Object
27 28 29 |
# File 'lib/refocus/subjects.rb', line 27 def delete(name:) json(http.delete(name)) end |
#get(name:) ⇒ Object
35 36 37 |
# File 'lib/refocus/subjects.rb', line 35 def get(name:) json(http.get(name)) end |
#update(name:, options:) ⇒ Object
31 32 33 |
# File 'lib/refocus/subjects.rb', line 31 def update(name:, options:) json(http.patch(name, body: )) end |