Class: Insika::StoredProfileSource
- Inherits:
-
Object
- Object
- Insika::StoredProfileSource
- Includes:
- Coercion, ProfileSource
- Defined in:
- lib/insika/profile_source.rb
Overview
Persisted source (Studio): reads/writes profiles in the ConfigStore (scope "agents").
Each fetch reads FRESH from the store — an edit via the Studio takes effect on
the next dispatch, without a restart. An in-flight turn keeps the profile it
captured (the Commands resolve at the start of #call), so the turn semantics are
preserved.
Constant Summary collapse
- SCOPE =
"agents"
Constants included from Coercion
Instance Method Summary collapse
- #all ⇒ Object
- #delete(id) ⇒ Object
- #fetch(id) ⇒ Object
- #ids ⇒ Object
-
#initialize(config_store:) ⇒ StoredProfileSource
constructor
A new instance of StoredProfileSource.
-
#put(profile) ⇒ Object
Write (used by the :create_agent/:update_agent Commands).
Methods included from Coercion
blank?, deep_stringify, presence, present?, truthy?, utf8
Methods included from ProfileSource
Constructor Details
#initialize(config_store:) ⇒ StoredProfileSource
Returns a new instance of StoredProfileSource.
57 58 59 |
# File 'lib/insika/profile_source.rb', line 57 def initialize(config_store:) @cs = config_store end |
Instance Method Details
#all ⇒ Object
66 |
# File 'lib/insika/profile_source.rb', line 66 def all = @cs.all(SCOPE).map { |r| deserialize(r) } |
#delete(id) ⇒ Object
75 |
# File 'lib/insika/profile_source.rb', line 75 def delete(id) = @cs.delete(SCOPE, id.to_s) |
#fetch(id) ⇒ Object
61 62 63 64 |
# File 'lib/insika/profile_source.rb', line 61 def fetch(id) record = @cs.get(SCOPE, id.to_s) record && deserialize(record) end |
#ids ⇒ Object
67 |
# File 'lib/insika/profile_source.rb', line 67 def ids = @cs.keys(SCOPE) |
#put(profile) ⇒ Object
Write (used by the :create_agent/:update_agent Commands).
70 71 72 73 |
# File 'lib/insika/profile_source.rb', line 70 def put(profile) @cs.put(SCOPE, profile.id, profile.to_h) profile end |