Module: Restrict::Rails::Controller::ClassMethods

Defined in:
lib/restrict/rails/controller.rb

Instance Method Summary collapse

Instance Method Details

#install_gatekeeperObject

This could happen in included block as well, but often you need other before filters to happen before you actually check the restrictions, so lets set it where it is used in the code as well.



20
21
22
23
24
# File 'lib/restrict/rails/controller.rb', line 20

def install_gatekeeper
  return if @gatekeeper_installed
  before_action :invoke_gatekeeper
  @gatekeeper_installed = true
end

#restrict(*args) ⇒ Object



11
12
13
14
15
# File 'lib/restrict/rails/controller.rb', line 11

def restrict(*args)
  install_gatekeeper
  self.restrictions ||= []
  restrictions << Restrict::Restriction.new(*args)
end