Class: ActionController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/can_do.rb

Instance Method Summary collapse

Instance Method Details

#can?(*args, &block) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/can_do.rb', line 22

def can?(*args, &block)
  CanDo.can?(*args, &block)
end

#deny_permission(reason, *args) ⇒ Object



34
35
36
# File 'lib/can_do.rb', line 34

def deny_permission(reason, *args)
  raise CanDo::PermissionError.new(reason)
end

#require_permission!(*args) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/can_do.rb', line 26

def require_permission!(*args)
  reason = CanDo.reason(*args)
  unless reason.nil?
    Rails.logger.info "Permission Error: #{reason}"
    deny_permission(reason, *args)
  end
end