Class: Textus::Application::Reads::Get
- Inherits:
-
Object
- Object
- Textus::Application::Reads::Get
- Defined in:
- lib/textus/application/reads/get.rb
Overview
Pure read: returns the on-disk envelope annotated with a freshness verdict. Never triggers refresh; never invokes the orchestrator.
For interactive reads that want refresh-on-stale, use ‘Reads::GetOrRefresh`, which composes this with the orchestrator.
Instance Method Summary collapse
- #call(key) ⇒ Object
-
#get(key) ⇒ Object
Strict variant: raises UnknownKey when the entry is missing.
-
#initialize(ctx:, evaluator: Textus::Domain::Freshness::Evaluator) ⇒ Get
constructor
A new instance of Get.
Constructor Details
Instance Method Details
#call(key) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/textus/application/reads/get.rb', line 15 def call(key) envelope = read_raw_envelope(key) return nil if envelope.nil? policy_set = @ctx.manifest.rules_for(key) refresh_policy = policy_set.refresh return annotate_fresh(envelope) if refresh_policy.nil? policy = refresh_policy.to_freshness_policy verdict = @evaluator.call(policy, envelope, now: @ctx.now) envelope.with(freshness: Textus::Domain::Freshness.build( stale: verdict.stale?, reason: verdict.reason, refreshing: false, )) end |
#get(key) ⇒ Object
Strict variant: raises UnknownKey when the entry is missing. Used by consumers (e.g. Validator) that need to distinguish absence from emptiness.
36 37 38 |
# File 'lib/textus/application/reads/get.rb', line 36 def get(key) call(key) || raise(UnknownKey.new(key, suggestions: @ctx.manifest.suggestions_for(key))) end |