Class: Textus::Domain::Freshness::Verdict

Inherits:
Data
  • Object
show all
Defined in:
lib/textus/domain/freshness/verdict.rb

Overview

Value object describing the freshness annotation attached to an Envelope after a currency evaluation (ADR 0099 — was Domain::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.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#checked_atObject (readonly)

Returns the value of attribute checked_at

Returns:

  • (Object)

    the current value of checked_at



14
15
16
# File 'lib/textus/domain/freshness/verdict.rb', line 14

def checked_at
  @checked_at
end

#fetch_errorObject (readonly)

Returns the value of attribute fetch_error

Returns:

  • (Object)

    the current value of fetch_error



14
15
16
# File 'lib/textus/domain/freshness/verdict.rb', line 14

def fetch_error
  @fetch_error
end

#fetchingObject (readonly)

Returns the value of attribute fetching

Returns:

  • (Object)

    the current value of fetching



14
15
16
# File 'lib/textus/domain/freshness/verdict.rb', line 14

def fetching
  @fetching
end

#reasonObject (readonly)

Returns the value of attribute reason

Returns:

  • (Object)

    the current value of reason



14
15
16
# File 'lib/textus/domain/freshness/verdict.rb', line 14

def reason
  @reason
end

#staleObject (readonly)

Returns the value of attribute stale

Returns:

  • (Object)

    the current value of stale



14
15
16
# File 'lib/textus/domain/freshness/verdict.rb', line 14

def stale
  @stale
end

#ttl_remaining_msObject (readonly)

Returns the value of attribute ttl_remaining_ms

Returns:

  • (Object)

    the current value of ttl_remaining_ms



14
15
16
# File 'lib/textus/domain/freshness/verdict.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
# File 'lib/textus/domain/freshness/verdict.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_wireObject



26
27
28
29
30
# File 'lib/textus/domain/freshness/verdict.rb', line 26

def to_h_for_wire
  h = { "stale" => stale, "stale_reason" => reason, "fetching" => fetching }
  h["fetch_error"] = fetch_error unless fetch_error.nil?
  h
end