Class: WCC::Data::RESTEndpoint
- Inherits:
-
Object
- Object
- WCC::Data::RESTEndpoint
- Defined in:
- lib/wcc/data/rest_endpoint.rb
Instance Attribute Summary collapse
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #create(attrs, options = {}) ⇒ Object
- #destroy(id, options = {}) ⇒ Object
- #index(options = {}) ⇒ Object
-
#initialize(args = {}) ⇒ RESTEndpoint
constructor
A new instance of RESTEndpoint.
- #show(id, options = {}) ⇒ Object
- #update(id, attrs, options = {}) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ RESTEndpoint
Returns a new instance of RESTEndpoint.
6 7 8 |
# File 'lib/wcc/data/rest_endpoint.rb', line 6 def initialize(args={}) @service = args[:service] end |
Instance Attribute Details
#service ⇒ Object (readonly)
Returns the value of attribute service.
4 5 6 |
# File 'lib/wcc/data/rest_endpoint.rb', line 4 def service @service end |
Instance Method Details
#create(attrs, options = {}) ⇒ Object
18 19 20 |
# File 'lib/wcc/data/rest_endpoint.rb', line 18 def create(attrs, ={}) service.post(.merge(body: attrs)) end |
#destroy(id, options = {}) ⇒ Object
26 27 28 |
# File 'lib/wcc/data/rest_endpoint.rb', line 26 def destroy(id, ={}) service.delete(.merge(uri: id.to_s)) end |
#index(options = {}) ⇒ Object
10 11 12 |
# File 'lib/wcc/data/rest_endpoint.rb', line 10 def index(={}) service.get() end |
#show(id, options = {}) ⇒ Object
14 15 16 |
# File 'lib/wcc/data/rest_endpoint.rb', line 14 def show(id, ={}) service.get(.merge(uri: id.to_s)) end |
#update(id, attrs, options = {}) ⇒ Object
22 23 24 |
# File 'lib/wcc/data/rest_endpoint.rb', line 22 def update(id, attrs, ={}) service.patch(.merge(uri: id.to_s, body: attrs)) end |