Module: Insika::ProfileSource
- Included in:
- StaticProfileSource, StoredProfileSource
- Defined in:
- lib/insika/profile_source.rb
Overview
Source of AgentProfiles. Profiles used to be a FROZEN Hash injected into the Executor and the turn Commands — static, defined in Ruby at wiring time. For the Studio to create/edit agents at runtime, the source needs to be MUTABLE and reloadable, without changing the consumption contract.
The consumption contract is minimal and duck-typed: source[id] -> AgentProfile|nil
(like a Hash). That's why the refactor in the Executor/Commands is just
normalizing the input (legacy Hash -> StaticProfileSource); the bodies that do
@profiles[agent] stay identical. all/ids are for the Studio to list.
nil from []/fetch = agent not configured (the Commands raise
NotFoundError) — NEVER raises (unlike Hash#fetch).
Class Method Summary collapse
-
.coerce(profiles) ⇒ Object
Normalizes the consumers' input: a legacy Hash becomes a StaticProfileSource; a ProfileSource passes straight through.
Instance Method Summary collapse
-
#[](id) ⇒ Object
Hash-compat sugar:
source[id].
Class Method Details
.coerce(profiles) ⇒ Object
Normalizes the consumers' input: a legacy Hash becomes a StaticProfileSource; a ProfileSource passes straight through. A single place for the compat seam.
23 24 25 26 27 |
# File 'lib/insika/profile_source.rb', line 23 def self.coerce(profiles) return profiles if profiles.is_a?(ProfileSource) StaticProfileSource.new(profiles || {}) end |
Instance Method Details
#[](id) ⇒ Object
Hash-compat sugar: source[id].
19 |
# File 'lib/insika/profile_source.rb', line 19 def [](id) = fetch(id) |