Class: Textus::Domain::Freshness::Policy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#on_staleObject (readonly)

Returns the value of attribute on_stale

Returns:

  • (Object)

    the current value of on_stale



4
5
6
# File 'lib/textus/domain/freshness/policy.rb', line 4

def on_stale
  @on_stale
end

#sync_budget_msObject (readonly)

Returns the value of attribute sync_budget_ms

Returns:

  • (Object)

    the current value of sync_budget_ms



4
5
6
# File 'lib/textus/domain/freshness/policy.rb', line 4

def sync_budget_ms
  @sync_budget_ms
end

#ttl_secondsObject (readonly)

Returns the value of attribute ttl_seconds

Returns:

  • (Object)

    the current value of ttl_seconds



4
5
6
# File 'lib/textus/domain/freshness/policy.rb', line 4

def ttl_seconds
  @ttl_seconds
end

Instance Method Details

#decide(verdict) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/textus/domain/freshness/policy.rb', line 5

def decide(verdict)
  return Action::Return.new if verdict.fresh?

  case on_stale
  when :warn       then Action::Return.new
  when :sync       then Action::RefreshSync.new
  when :timed_sync then Action::RefreshTimed.new(budget_ms: sync_budget_ms)
  else                  Action::Return.new
  end
end