debian-mirror-gitlab/config/initializers/active_record_preloader.rb

29 lines
545 B
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
module ActiveRecord
module Associations
class Preloader
2019-09-30 21:07:59 +05:30
class NullPreloader
def self.new(klass, owners, reflection, preload_scope)
self
end
2020-03-13 15:44:24 +05:30
def self.run
2019-09-30 21:07:59 +05:30
end
def self.preloaded_records
[]
end
end
2017-09-10 17:25:29 +05:30
module NoCommitPreloader
2019-09-30 21:07:59 +05:30
def preloader_for(reflection, owners)
return NullPreloader if owners.first.association(reflection.name).klass == ::Commit
2017-09-10 17:25:29 +05:30
super
end
end
prepend NoCommitPreloader
end
end
end