Module: AccessGranted::Rails::ControllerMethods

Defined in:
lib/access-granted/rails/controller_methods.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
# File 'lib/access-granted/rails/controller_methods.rb', line 8

def self.included(base)
  base.helper_method :can?, :cannot?, :current_policy if base.respond_to? :helper_method
end

Instance Method Details

#authorize!(*args) ⇒ Object



20
21
22
# File 'lib/access-granted/rails/controller_methods.rb', line 20

def authorize!(*args)
  current_policy.authorize!(*args)
end

#can?(*args) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/access-granted/rails/controller_methods.rb', line 12

def can?(*args)
  current_policy.can?(*args)
end

#cannot?(*args) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/access-granted/rails/controller_methods.rb', line 16

def cannot?(*args)
  current_policy.cannot?(*args)
end

#current_policyObject



4
5
6
# File 'lib/access-granted/rails/controller_methods.rb', line 4

def current_policy
  @current_policy ||= ::AccessPolicy.new(current_user)
end