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”, “fetching”, and “fetch_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.
-
#fetch_error ⇒ Object
readonly
Returns the value of attribute fetch_error.
-
#fetching ⇒ Object
readonly
Returns the value of attribute fetching.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#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 |
#fetch_error ⇒ Object (readonly)
Returns the value of attribute fetch_error
14 15 16 |
# File 'lib/textus/domain/freshness.rb', line 14 def fetch_error @fetch_error end |
#fetching ⇒ Object (readonly)
Returns the value of attribute fetching
14 15 16 |
# File 'lib/textus/domain/freshness.rb', line 14 def fetching @fetching 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 |
#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:, fetching: false, reason: nil, fetch_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:, fetching: false, reason: nil, fetch_error: nil, checked_at: nil, ttl_remaining_ms: nil) new( stale: stale, fetching: fetching, reason: reason, fetch_error: fetch_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, "fetching" => fetching, } h["fetch_error"] = fetch_error unless fetch_error.nil? h end |