Class: SimpleCrud::Authorization::PunditAdapter

Inherits:
Object
  • Object
show all
Includes:
Adapter
Defined in:
lib/simple_crud/authorization/pundit_adapter.rb

Overview

Default authorization adapter: standard Pundit #{Model}Policy classes.

Instance Method Summary collapse

Instance Method Details

#authorize(controller, record) ⇒ Object



11
12
13
14
# File 'lib/simple_crud/authorization/pundit_adapter.rb', line 11

def authorize(controller, record)
  # Pundit::Authorization#authorize is protected, hence send.
  controller.send(:authorize, record)
end

#policy_defined?(model_class) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/simple_crud/authorization/pundit_adapter.rb', line 16

def policy_defined?(model_class)
  Kernel.const_defined?("#{model_class}Policy")
end