Class: RubyRest::SimpleApplication
- Inherits:
-
AbstractApplication
- Object
- AbstractApplication
- RubyRest::SimpleApplication
- Defined in:
- lib/rubyrest/application.rb
Overview
Basic CRUD application
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from AbstractApplication
Instance Method Summary collapse
-
#create(params) ⇒ Object
Invoked by the web layer, on a POST request.
-
#delete(params) ⇒ Object
Invoked by the web layer, on a DELETE request.
-
#retrieve(params) ⇒ Object
Invoked by the web layer, on a GET request.
-
#update(params) ⇒ Object
Invoked by the web layer, on a PUT request This method delegates to the resource’s service and provides an existing model object, loaded and populated with the data found in the request body.
Methods inherited from AbstractApplication
#formatter, #init_database, #initialize, #is_a_collection, #is_a_service_doc, #register_domain, #register_formatters, #register_resource, #render_model, #resource_by_domain, #resource_by_name, #resource_by_path, #setup, #to_domain_class, #to_resource_class, #to_s
Constructor Details
This class inherits a constructor from RubyRest::AbstractApplication
Instance Method Details
#create(params) ⇒ Object
Invoked by the web layer, on a POST request. This method delegates to the resource’s service and provides a fresh new model object populated with the data found in the request body.
142 143 144 145 |
# File 'lib/rubyrest/application.rb', line 142 def create( params ) res = resource_by_path( params[:path] ) render_model( params, res.domain.create( params[:body] ) ) end |
#delete(params) ⇒ Object
Invoked by the web layer, on a DELETE request
156 157 158 159 |
# File 'lib/rubyrest/application.rb', line 156 def delete( params ) res = resource_by_path( params[:path] ) res.domain.delete( params[:target] ) end |
#retrieve(params) ⇒ Object
Invoked by the web layer, on a GET request. Retrieves the collection or resource, and formats the result as a feed, entry or service document
133 134 135 136 |
# File 'lib/rubyrest/application.rb', line 133 def retrieve( params ) res = resource_by_path( params[:path] ) render_model( params, res.domain.retrieve( params[:target], params[:property] ) ) end |
#update(params) ⇒ Object
Invoked by the web layer, on a PUT request This method delegates to the resource’s service and provides an existing model object, loaded and populated with the data found in the request body.
150 151 152 153 |
# File 'lib/rubyrest/application.rb', line 150 def update( params ) res = resource_by_path( params[:path] ) render_model( params, res.domain.update( params[:target], params[:body] ) ) end |