Class: Insika::PolicyRegistry

Inherits:
Registry
  • Object
show all
Defined in:
lib/insika/policy_registry.rb

Overview

Policy registry. resolve(name) -> Policy::Base. The builtins (ToolAllowlist/SkillAllowlist/WorkflowAllowlist) are registered AT BOOT by the composition root (config/wiring.rb), not here.

NB: the Policy::Engine consumes via fetch(name); a Hash also satisfies that duck-type. This registry is the production implementation — to use it with the Engine, expose fetch delegating to resolve.

Instance Method Summary collapse

Methods inherited from Registry

#deregister_plugin, #entries, #entry, #initialize, #names, #register

Constructor Details

This class inherits a constructor from Insika::Registry

Instance Method Details

#fetch(name) ⇒ Object

Alias for the duck-type the Policy::Engine expects (fetch(name) -> Policy::Base).



21
# File 'lib/insika/policy_registry.rb', line 21

def fetch(name) = resolve(name)

#resolve(name) ⇒ Object

-> Policy::Base (INSTANCE): the Engine calls #decide on the result. If the policy was registered as a CLASS, instantiate it; if it already came as an instance/factory returning an instance, pass it through.



15
16
17
18
# File 'lib/insika/policy_registry.rb', line 15

def resolve(name)
  resolved = super
  resolved.is_a?(Class) ? resolved.new : resolved
end