Class: Btspm::EagerLoadable::EagerLoader
- Inherits:
-
Object
- Object
- Btspm::EagerLoadable::EagerLoader
- Defined in:
- lib/btspm/eager_loadable.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(coll, *assocs) ⇒ EagerLoader
constructor
A new instance of EagerLoader.
- #load ⇒ Object
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
#load ⇒ Object
20 21 22 23 |
# File 'lib/btspm/eager_loadable.rb', line 20 def load preloader = ActiveRecord::Associations::Preloader.new preloader.preload(collection, associations) end |