Module: MarbleGate::ControllerClassMethods

Defined in:
lib/marble_gate/controller_class_methods.rb

Instance Method Summary collapse

Instance Method Details

#authorize!(cls = nil, *args, only: [], except: []) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/marble_gate/controller_class_methods.rb', line 9

def authorize!(cls = nil, *args, only: [], except: [])
  cls = cls || controller_name.classify.constantize

  before_action(only: only, except: except) do
    res = MarbleGate.access(self, params[:action], *args).for_authorizer?(cls)
    raise MarbleGate::AccessDenied unless res
  end
end