Module: RESTFramework::BaseControllerMixin
- Included in:
- BaseModelControllerMixin
- Defined in:
- lib/rest_framework/controller_mixins/base.rb
Overview
This module provides the common functionality for any controller mixins, a ‘root` action, and the ability to route arbitrary actions with `extra_actions`. This is also where `api_response` is defined.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#root ⇒ Object
Default action for API root.
Class Method Details
.included(base) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rest_framework/controller_mixins/base.rb', line 28 def self.included(base) if base.is_a? Class base.extend ClassMethods base.class_attribute(*[ :singleton_controller, :extra_actions, :skip_actions, :paginator_class, ]) base.rescue_from(ActiveRecord::RecordNotFound, with: :record_not_found) base.rescue_from(ActiveRecord::RecordInvalid, with: :record_invalid) base.rescue_from(ActiveRecord::RecordNotSaved, with: :record_not_saved) base.rescue_from(ActiveRecord::RecordNotDestroyed, with: :record_not_destroyed) end end |
Instance Method Details
#root ⇒ Object
Default action for API root.
8 9 10 |
# File 'lib/rest_framework/controller_mixins/base.rb', line 8 def root api_response({message: "This is the root of your awesome API!"}) end |