Class: SmartCollection::Associations::Preloader::SmartCollectionCachedByTable

Inherits:
ActiveRecord::Associations::Preloader::HasManyThrough
  • Object
show all
Defined in:
lib/smart_collection/associations/preloader/smart_collection.rb

Instance Method Summary collapse

Instance Method Details

#associated_records_by_owner(preloader) ⇒ Object



14
15
16
17
# File 'lib/smart_collection/associations/preloader/smart_collection.rb', line 14

def associated_records_by_owner preloader
  owners.reject(&:cache_exists?).each(&:update_cache)
  super
end

#source_reflectionObject



9
10
11
12
# File 'lib/smart_collection/associations/preloader/smart_collection.rb', line 9

def source_reflection
  association_name = reflection.options[:smart_collection].item_name
  through_reflection.klass.reflect_on_association(association_name)
end

#through_reflectionObject



5
6
7
# File 'lib/smart_collection/associations/preloader/smart_collection.rb', line 5

def through_reflection
  reflection.active_record.reflect_on_association(:cached_items)
end