Module: ActiveRecord::Materialized::Metadata::Timestamps Private

Extended by:
T::Sig
Defined in:
lib/activerecord/materialized/metadata/timestamps.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Current-time and staleness-threshold helpers for metadata timestamps.

Class Method Summary collapse

Class Method Details

.currentObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/activerecord/materialized/metadata/timestamps.rb', line 16

def current
  ::Time.zone&.now || ::Time.now.utc
end

.threshold(staleness) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
24
25
26
27
# File 'lib/activerecord/materialized/metadata/timestamps.rb', line 21

def threshold(staleness)
  if staleness.is_a?(Integer)
    ::ActiveSupport::Duration.seconds(staleness).ago
  else
    staleness.ago
  end
end