Class: RubyUIAdmin::BasePolicy

Inherits:
ActionPolicy::Base
  • Object
show all
Defined in:
lib/ruby_ui_admin/base_policy.rb

Overview

Base class for admin policies. Host policies (RubyUIAdmin::Policies::*) inherit from this. It lives outside the RubyUIAdmin::Policies namespace so Zeitwerk can fully own that namespace for host-defined policies.

Migration note: a host's existing base policy maps to this class.

manage? is action_policy's default rule (fallback for any rule the host policy doesn't define). We defer it to explicit_authorization: when explicit_authorization is false, undefined rules are allowed; when true, they are denied.

Instance Method Summary collapse

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


30
# File 'lib/ruby_ui_admin/base_policy.rb', line 30

def create? = manage?

#index?Boolean

index? and create? are concretely defined as false by action_policy's Defaults module, so redirect them to the same fallback as every other rule.

Returns:

  • (Boolean)


28
# File 'lib/ruby_ui_admin/base_policy.rb', line 28

def index? = manage?

#manage?Boolean

Returns:

  • (Boolean)


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

def manage?
  !RubyUIAdmin.configuration.explicit_authorization
end