Sha256: 3442799f524e3fa595a57e7d2b5415ff7472f0008712f2914ed85b10f341c390

Contents?: true

Size: 540 Bytes

Versions: 1

Compression:

Stored size: 540 Bytes

Contents

module TemporalTables
	# Uses the at time when fetching preloaded records
	module PreloaderExtensions
		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
	end
end

ActiveRecord::Associations::Preloader::Association.prepend TemporalTables::PreloaderExtensions

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
temporal_tables-0.6.10 lib/temporal_tables/preloader_extensions.rb