Class: Dase::Preloader
- Inherits:
-
ActiveRecord::Associations::Preloader
- Object
- ActiveRecord::Associations::Preloader
- Dase::Preloader
- Defined in:
- lib/dase/preloader.rb
Defined Under Namespace
Classes: HasAndBelongsToMany, HasMany, HasManyThrough
Instance Method Summary collapse
-
#preloader_for(reflection) ⇒ Object
an overloaded version of ActiveRecord::Associations::Preloader’s preloader_for which returns a class of a custom preloader for a given association.
Instance Method Details
#preloader_for(reflection) ⇒ Object
an overloaded version of ActiveRecord::Associations::Preloader’s preloader_for which returns a class of a custom preloader for a given association
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dase/preloader.rb', line 30 def preloader_for(reflection) case reflection.macro when :has_many if reflection.[:through] HasManyThrough #raise NotImplementedError, "The support for HasManyThrough associations is not implemented yet" else HasMany end when :has_one, :belongs_to raise ArgumentError, "You can't use includes_count_of with a #{reflection.macro} association" when :has_and_belongs_to_many HasAndBelongsToMany end end |