Class: Serega::SeregaPlugins::ActiverecordPreloads::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/serega/plugins/activerecord_preloads/lib/preloader.rb

Overview

Associations loader for prepared records

Class Method Summary collapse

Class Method Details

.call(records, associations) ⇒ void

This method returns an undefined value.

Preloads associations to records

Parameters:

  • records (Array<ActiveRecord::Base>)

    records

  • associations (Hash)

    associations names



50
51
52
53
54
55
56
# File 'lib/serega/plugins/activerecord_preloads/lib/preloader.rb', line 50

def self.call(records, associations)
  if ActiveRecord::VERSION::MAJOR >= 7
    ActiveRecord::Associations::Preloader.new(records: records, associations: associations).call
  else
    ActiveRecord::Associations::Preloader.new.preload(records, associations)
  end
end