lib/bullet/detector/counter_cache.rb in bullet-4.11.3 vs lib/bullet/detector/counter_cache.rb in bullet-4.12.0
- old
+ new
@@ -3,11 +3,11 @@
class CounterCache < Base
class <<self
def add_counter_cache(object, associations)
return unless Bullet.start?
return unless Bullet.counter_cache_enable?
- return unless object.id
+ return unless object.primary_key_value
Bullet.debug("Detector::CounterCache#add_counter_cache", "object: #{object.bullet_key}, associations: #{associations}")
if conditions_met?(object.bullet_key, associations)
create_notification object.class.to_s, associations
end
@@ -15,19 +15,19 @@
def add_possible_objects(object_or_objects)
return unless Bullet.start?
return unless Bullet.counter_cache_enable?
objects = Array(object_or_objects)
- return if objects.map(&:id).compact.empty?
+ return if objects.map(&:primary_key_value).compact.empty?
Bullet.debug("Detector::CounterCache#add_possible_objects", "objects: #{objects.map(&:bullet_key).join(', ')}")
objects.each { |object| possible_objects.add object.bullet_key }
end
def add_impossible_object(object)
return unless Bullet.start?
return unless Bullet.counter_cache_enable?
- return unless object.id
+ return unless object.primary_key_value
Bullet.debug("Detector::CounterCache#add_impossible_object", "object: #{object.bullet_key}")
impossible_objects.add object.bullet_key
end