Module: SmartCollection::ActiveRecordPreloaderPatch

Defined in:
lib/smart_collection/associations/preloader/smart_collection.rb

Instance Method Summary collapse

Instance Method Details

#preloader_for(reflection, owners, rhs_klass) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/smart_collection/associations/preloader/smart_collection.rb', line 36

def preloader_for(reflection, owners, rhs_klass)
  config = reflection.options[:smart_collection]
  if config
    case config.cache_manager
    when SmartCollection::CacheManager::CacheStore
      SmartCollection::Associations::Preloader::SmartCollectionCachedByCacheStore
    when SmartCollection::CacheManager::Table
      SmartCollection::Associations::Preloader::SmartCollectionCachedByTable
    else
      raise RuntimeError, "Turn on cache to enable preloading."
    end
  else
    super
  end
end