Class: Textus::Application::Read::Get::Impl
- Inherits:
-
Object
- Object
- Textus::Application::Read::Get::Impl
- Defined in:
- lib/textus/application/read/get.rb
Instance Method Summary collapse
- #call(key) ⇒ Object
-
#get(key) ⇒ Object
Strict variant: raises UnknownKey when the entry is missing.
-
#initialize(ctx:, caps:, evaluator: Textus::Domain::Freshness::Evaluator) ⇒ Impl
constructor
A new instance of Impl.
Constructor Details
#initialize(ctx:, caps:, evaluator: Textus::Domain::Freshness::Evaluator) ⇒ Impl
Returns a new instance of Impl.
15 16 17 18 19 20 |
# File 'lib/textus/application/read/get.rb', line 15 def initialize(ctx:, caps:, evaluator: Textus::Domain::Freshness::Evaluator) @ctx = ctx @manifest = caps.manifest @file_store = caps.file_store @evaluator = evaluator end |
Instance Method Details
#call(key) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/textus/application/read/get.rb', line 22 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.
43 44 45 |
# File 'lib/textus/application/read/get.rb', line 43 def get(key) call(key) || raise(UnknownKey.new(key, suggestions: @manifest.resolver.suggestions_for(key))) end |