Module: TemporalTables::PreloaderExtensions

Defined in:
lib/temporal_tables/preloader_extensions.rb

Overview

Uses the at time when fetching preloaded records

Instance Method Summary collapse

Instance Method Details

#build_scopeObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/temporal_tables/preloader_extensions.rb', line 6

def build_scope
  # It seems the at time can be in either of these places, but not both,
  # depending on when the preloading happens to be done
  at_time = @owners.first.at_value if @owners.first.respond_to?(:at_value)
  at_time ||= Thread.current[:at_time]

  if at_time
    super.at(at_time)
  else
    super
  end
end