Module: Cannie::ControllerExtensions::ClassMethods
- Defined in:
- lib/cannie/controller_extensions.rb
Instance Method Summary collapse
-
#check_permissions(options = {}) ⇒ Object
Method is used to be sure, that permissions checking is handled for each action inside controller.
-
#skip_check_permissions(*args) ⇒ Object
Skip handling of permissions checking, that was defined by ‘check_permissions` method.
Instance Method Details
#check_permissions(options = {}) ⇒ Object
Method is used to be sure, that permissions checking is handled for each action inside controller.
class PostsController < ApplicationController
# ...
end
18 19 20 21 22 23 24 25 26 |
# File 'lib/cannie/controller_extensions.rb', line 18 def ( = {}) _if, _unless = .values_at(:if, :unless) before_action(.slice(:only, :except)) do |controller| next if controller.permitted? next if _if && !controller.instance_eval(&_if) next if _unless && controller.instance_eval(&_unless) .permit!(controller.action_name, controller) end end |
#skip_check_permissions(*args) ⇒ Object
Skip handling of permissions checking, that was defined by ‘check_permissions` method
class PostsController < ApplicationController
# ...
end
35 36 37 38 39 |
# File 'lib/cannie/controller_extensions.rb', line 35 def (*args) prepend_before_action(*args) do |controller| controller.instance_variable_set(:@_permitted, true) end end |