module DroidServices::Extensions::HasService
Public Instance Methods
build()
click to toggle source
# File lib/droid_services/extensions/has_service.rb, line 9 def build respond_with build_resource(nil) end
collection()
click to toggle source
# File lib/droid_services/extensions/has_service.rb, line 5 def collection respond_with decorated_collection, collection_name end
create(custom_attributes=nil)
click to toggle source
# File lib/droid_services/extensions/has_service.rb, line 13 def create(custom_attributes=nil) resource = build_resource(nil, custom_attributes||resource_attributes) invoke_callback(:before_create, resource) invoke_callback(:before_save, resource) if resource.save invoke_callback(:after_create, resource) invoke_callback(:after_save, resource) set_message("#{resource_name.titleize} successfully created") else add_errors_from(resource) end respond_with(resource) end
destroy()
click to toggle source
# File lib/droid_services/extensions/has_service.rb, line 47 def destroy resource = find_resource(params[:id]) invoke_callback(:before_destroy, resource) resource.destroy invoke_callback(:after_destroy, resource) respond_with(resource) end
read()
click to toggle source
# File lib/droid_services/extensions/has_service.rb, line 27 def read respond_with find_resource(params[:id]) end
Also aliased as: edit
update(custom_attributes=nil)
click to toggle source
# File lib/droid_services/extensions/has_service.rb, line 33 def update(custom_attributes=nil) resource = build_resource(params[:id], custom_attributes||resource_attributes) invoke_callback(:before_update, resource) invoke_callback(:before_save, resource) if resource.save invoke_callback(:after_update, resource) invoke_callback(:after_save, resource) set_message("#{resource_name.titleize} successfully updated") else add_errors_from(resource) end respond_with(resource) end