Class: Btspm::EagerLoadable::EagerLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/btspm/eager_loadable.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coll, *assocs) ⇒ EagerLoader



9
10
11
12
# File 'lib/btspm/eager_loadable.rb', line 9

def initialize(coll, *assocs)
  @collection = coll
  @associations = assocs
end

Class Method Details

.load(collection, *associations) ⇒ Object



14
15
16
17
18
# File 'lib/btspm/eager_loadable.rb', line 14

def self.load(collection, *associations)
  preloader = new(collection, *associations)
  preloader.load
  collection
end

Instance Method Details

#loadObject



20
21
22
23
# File 'lib/btspm/eager_loadable.rb', line 20

def load
  preloader = ActiveRecord::Associations::Preloader.new
  preloader.preload(collection, associations)
end