Module: Eipiai::SingularResource
- Defined in:
- lib/eipiai/resources/singular.rb
Overview
SingularResource
The singular resource is the basis for a resource representing a single object.
It provides basic GET, PUT and DELETE support.
It is the singular version of the ‘CollectionResource` resource.
Instance Method Summary collapse
- #allowed_methods ⇒ Object
- #create_path ⇒ Object
- #delete_resource ⇒ Object
- #from_json ⇒ Object
- #resource_exists? ⇒ Boolean
Instance Method Details
#allowed_methods ⇒ Object
19 20 21 |
# File 'lib/eipiai/resources/singular.rb', line 19 def allowed_methods %w(GET POST PUT DELETE) end |
#create_path ⇒ Object
27 28 29 |
# File 'lib/eipiai/resources/singular.rb', line 27 def create_path request.uri.path end |
#delete_resource ⇒ Object
31 32 33 34 35 36 |
# File 'lib/eipiai/resources/singular.rb', line 31 def delete_resource object.destroy @object = nil true end |
#from_json ⇒ Object
38 39 40 |
# File 'lib/eipiai/resources/singular.rb', line 38 def from_json request.put? ? put_from_json : post_from_json end |
#resource_exists? ⇒ Boolean
23 24 25 |
# File 'lib/eipiai/resources/singular.rb', line 23 def resource_exists? object.present? end |