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:, manifest:, file_store:, evaluator: Textus::Domain::Freshness::Evaluator) ⇒ Get
constructor
A new instance of Get.
Constructor Details
#initialize(ctx:, manifest:, file_store:, evaluator: Textus::Domain::Freshness::Evaluator) ⇒ Get
Returns a new instance of Get.
10 11 12 13 14 15 |
# File 'lib/textus/application/reads/get.rb', line 10 def initialize(ctx:, manifest:, file_store:, evaluator: Textus::Domain::Freshness::Evaluator) @ctx = ctx @manifest = manifest @file_store = file_store @evaluator = evaluator end |
Instance Method Details
#call(key) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/textus/application/reads/get.rb', line 17 def call(key) envelope = read_raw_envelope(key) return nil if envelope.nil? policy_set = @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.
38 39 40 |
# File 'lib/textus/application/reads/get.rb', line 38 def get(key) call(key) || raise(UnknownKey.new(key, suggestions: @manifest.resolver.suggestions_for(key))) end |