Class: Textus::Domain::Freshness
- Inherits:
-
Data
- Object
- Data
- Textus::Domain::Freshness
- Defined in:
- lib/textus/domain/freshness.rb,
lib/textus/domain/freshness/policy.rb,
lib/textus/domain/freshness/verdict.rb,
lib/textus/domain/freshness/evaluator.rb
Overview
Value object describing the freshness annotation attached to an Envelope after a freshness evaluation. Replaces the loose Hash that used to live on ‘Envelope#freshness`.
Note on wire format: ‘#to_h_for_wire` is intentionally narrower than the full field set. It emits the legacy keys (“stale”, “stale_reason”, “refreshing”, and “refresh_error” when present) so the CLI JSON wire stays byte-identical with textus/3. The gem-side fields `checked_at` and `ttl_remaining_ms` are NOT emitted on the wire in this phase.
Defined Under Namespace
Modules: Evaluator Classes: Policy, Verdict
Instance Attribute Summary collapse
-
#checked_at ⇒ Object
readonly
Returns the value of attribute checked_at.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#refresh_error ⇒ Object
readonly
Returns the value of attribute refresh_error.
-
#refreshing ⇒ Object
readonly
Returns the value of attribute refreshing.
-
#stale ⇒ Object
readonly
Returns the value of attribute stale.
-
#ttl_remaining_ms ⇒ Object
readonly
Returns the value of attribute ttl_remaining_ms.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#checked_at ⇒ Object (readonly)
Returns the value of attribute checked_at
14 15 16 |
# File 'lib/textus/domain/freshness.rb', line 14 def checked_at @checked_at end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason
14 15 16 |
# File 'lib/textus/domain/freshness.rb', line 14 def reason @reason end |
#refresh_error ⇒ Object (readonly)
Returns the value of attribute refresh_error
14 15 16 |
# File 'lib/textus/domain/freshness.rb', line 14 def refresh_error @refresh_error end |
#refreshing ⇒ Object (readonly)
Returns the value of attribute refreshing
14 15 16 |
# File 'lib/textus/domain/freshness.rb', line 14 def refreshing @refreshing end |
#stale ⇒ Object (readonly)
Returns the value of attribute stale
14 15 16 |
# File 'lib/textus/domain/freshness.rb', line 14 def stale @stale end |
#ttl_remaining_ms ⇒ Object (readonly)
Returns the value of attribute ttl_remaining_ms
14 15 16 |
# File 'lib/textus/domain/freshness.rb', line 14 def ttl_remaining_ms @ttl_remaining_ms end |
Class Method Details
.build(stale:, refreshing: false, reason: nil, refresh_error: nil, checked_at: nil, ttl_remaining_ms: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/textus/domain/freshness.rb', line 17 def self.build(stale:, refreshing: false, reason: nil, refresh_error: nil, checked_at: nil, ttl_remaining_ms: nil) new( stale: stale, refreshing: refreshing, reason: reason, refresh_error: refresh_error, checked_at: checked_at, ttl_remaining_ms: ttl_remaining_ms, ) end |
Instance Method Details
#to_h_for_wire ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/textus/domain/freshness.rb', line 29 def to_h_for_wire h = { "stale" => stale, "stale_reason" => reason, "refreshing" => refreshing, } h["refresh_error"] = refresh_error unless refresh_error.nil? h end |