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

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.



12
13
14
# File 'lib/activerecord/materialized/metadata/timestamps.rb', line 12

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.



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

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