Module: Strongbolt::BoltedController
- Defined in:
- lib/strongbolt/bolted_controller.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Constant Summary collapse
- ACTIONS_MAPPING =
Maps controller actions to CRUD operations
{ index: :find, show: :find, edit: :update, update: :update, new: :create, create: :create, destroy: :destroy }.freeze
Class Method Summary collapse
Class Method Details
.included(receiver) ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/strongbolt/bolted_controller.rb', line 257 def self.included(receiver) receiver.class_eval do # Compulsory filters before_action :set_current_user after_action :unset_current_user # Catch Grant error around_action :catch_grant_error # Quick check of high level authorization before_action :check_authorization # A list storing actions that render without authorization self.class.send :attr_accessor, :actions_without_authorization # To allow render without authorization alias_method :_render, :render # Catch errors rescue_from Strongbolt::Unauthorized, Grant::Error do |e| if respond_to? :unauthorized e else raise Strongbolt::Unauthorized, e.to_s end end end # End receiver class eval receiver.extend ClassMethods receiver.send :include, InstanceMethods end |