Module: AccessGranted::ControllerMethods

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

def self.included(base)
  base.helper_method :can?, :cannot?, :current_ability
end

Instance Method Details

#authorize!(*args) ⇒ Object



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

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

#can?(*args) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#cannot?(*args) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#current_policyObject



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

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