Module: ArAsyncCounterCache::ActiveRecord
- Defined in:
- lib/ar_async_counter_cache/active_record.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
68 69 70 |
# File 'lib/ar_async_counter_cache/active_record.rb', line 68 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#update_async_counters(dir, *association_ids) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/ar_async_counter_cache/active_record.rb', line 5 def update_async_counters(dir, *association_ids) association_ids.each do |association_id| reflection = self.class.reflect_on_association(association_id) parent_class = reflection.klass column = self.class.async_counter_types[association_id] if parent_id = send(reflection.primary_key_name) ArAsyncCounterCache::IncrementCountersWorker.cache_and_enqueue(parent_class, parent_id, column, dir) end end end |