2021-02-03 16:09:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-31 12:12:21 -04:00
|
|
|
module ActiveRecord
|
|
|
|
module Associations
|
|
|
|
class Preloader
|
2019-06-25 13:54:42 -04:00
|
|
|
class NullPreloader
|
|
|
|
def self.new(klass, owners, reflection, preload_scope)
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2020-01-29 13:08:47 -05:00
|
|
|
def self.run
|
2021-03-17 08:09:19 -04:00
|
|
|
self
|
2019-06-25 13:54:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.preloaded_records
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-31 12:12:21 -04:00
|
|
|
module NoCommitPreloader
|
2019-06-25 13:54:42 -04:00
|
|
|
def preloader_for(reflection, owners)
|
|
|
|
return NullPreloader if owners.first.association(reflection.name).klass == ::Commit
|
2017-05-31 12:12:21 -04:00
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
prepend NoCommitPreloader
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|