Module: Authorization::Base::ControllerClassMethods

Defined in:
lib/rails-authorization-plugin/lib/authorization.rb

Instance Method Summary collapse

Instance Method Details

#permit(authorization_expression, *args) ⇒ Object

Allow class-level authorization check. permit is used in a before_action fashion and passes arguments to the before_action.


31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rails-authorization-plugin/lib/authorization.rb', line 31

def permit(authorization_expression, *args)
  filter_keys = [:only, :except]
  filter_args, eval_args = {}, {}
  if args.last.is_a? Hash
    filter_args.merge!(args.last.reject { |k, _v| not filter_keys.include? k })
    eval_args.merge!(args.last.reject { |k, _v| filter_keys.include? k })
  end
  before_action(filter_args) do |controller|
    controller.permit(authorization_expression, eval_args)
  end
end