Class: Preloaders::CommitStatusPreloader

Inherits:
Object
  • Object
show all
Defined in:
app/models/preloaders/commit_status_preloader.rb

Constant Summary collapse

CLASSES =
[::Ci::Build, ::Ci::Bridge, ::GenericCommitStatus].freeze

Instance Method Summary collapse

Constructor Details

#initialize(statuses) ⇒ CommitStatusPreloader

Returns a new instance of CommitStatusPreloader.


7
8
9
# File 'app/models/preloaders/commit_status_preloader.rb', line 7

def initialize(statuses)
  @statuses = statuses
end

Instance Method Details

#execute(relations) ⇒ Object


11
12
13
14
15
16
17
# File 'app/models/preloaders/commit_status_preloader.rb', line 11

def execute(relations)
  preloader = ActiveRecord::Associations::Preloader.new

  CLASSES.each do |klass|
    preloader.preload(objects(klass), associations(klass, relations))
  end
end