Welcome to mirror list, hosted at ThFree Co, Russian Federation.

active_record_preloader.rb « initializers « config - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 257a8a9e955d836f96bac9151c7b179dab38095e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

module ActiveRecord
  module Associations
    class Preloader
      class NullPreloader
        def self.new(klass, owners, reflection, preload_scope)
          self
        end

        def self.run
          self
        end

        def self.preloaded_records
          []
        end
      end

      module NoCommitPreloader
        def preloader_for(reflection, owners)
          return NullPreloader if owners.first.association(reflection.name).klass == ::Commit

          super
        end
      end

      prepend NoCommitPreloader
    end
  end
end