Module: Garage::RestfulActions

Extended by:
ActiveSupport::Concern
Included in:
Meta::DocsController, Meta::ServicesController
Defined in:
lib/garage/restful_actions.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#createObject

Public: Create a new resource Calls ‘create_resource` in your controller to create a new resource Requires `:write` permission on `resource_class` specified for `@resources`



71
72
73
74
# File 'lib/garage/restful_actions.rb', line 71

def create
  @resource = create_resource
  respond_with @resource, :location => location
end

#destroyObject

Public: Delete the resource Calls ‘destroy_resource` in your controller to destroy `@resource` Requires `:write` permission on `@resource`



87
88
89
90
# File 'lib/garage/restful_actions.rb', line 87

def destroy
  @resource = destroy_resource
  respond_with @resource, respond_with_resource_options
end

#indexObject

Public: List resources Renders ‘@resources` with options specified with `respond_with_resources_options` Requires `:read` permission on `resource_class` specified for `@resources`



57
58
59
# File 'lib/garage/restful_actions.rb', line 57

def index
  respond_with @resources, respond_with_resources_options
end

#showObject

Public: Get the resource Renders ‘@resource` with options specified with `respond_with_resource_options` Requires `:read` permission on `@resource`



64
65
66
# File 'lib/garage/restful_actions.rb', line 64

def show
  respond_with @resource, respond_with_resource_options
end

#updateObject

Public: Update the resource Calls ‘update_resource` in your controller to update `@resource` Requires `:write` permission on `@resource`



79
80
81
82
# File 'lib/garage/restful_actions.rb', line 79

def update
  @resource = update_resource
  respond_with @resource, respond_with_resource_options
end