Skip to content

Commit

Permalink
fix count method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
flyerhzm committed Oct 6, 2023
1 parent 01a0600 commit 95ffb25
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/bullet/active_record4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ def has_cached_counter?(reflection = reflection())
end

::ActiveRecord::Associations::CollectionProxy.class_eval do
def count
def count(column_name = nil, options = {})
if Bullet.start?
Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
end
super
super(column_name, options)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bullet/active_record41.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ def count_records
end

::ActiveRecord::Associations::CollectionProxy.class_eval do
def count
def count(column_name = nil, options = {})
if Bullet.start?
Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
end
super
super(column_name, options)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bullet/active_record42.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ def count_records
end

::ActiveRecord::Associations::CollectionProxy.class_eval do
def count
def count(column_name = nil, options = {})
if Bullet.start?
Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
end
super
super(column_name, options)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bullet/active_record52.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,14 @@ def count_records

::ActiveRecord::Associations::CollectionProxy.prepend(
Module.new do
def count
def count(column_name = nil)
if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
Bullet::Detector::CounterCache.add_counter_cache(
proxy_association.owner,
proxy_association.reflection.name
)
end
super
super(column_name)
end
end
)
Expand Down
4 changes: 2 additions & 2 deletions lib/bullet/active_record61.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,14 @@ def count_records

::ActiveRecord::Associations::CollectionProxy.prepend(
Module.new do
def count
def count(column_name = nil)
if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
Bullet::Detector::CounterCache.add_counter_cache(
proxy_association.owner,
proxy_association.reflection.name
)
end
super
super(column_name)
end
end
)
Expand Down
4 changes: 2 additions & 2 deletions lib/bullet/active_record70.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ def count_records

::ActiveRecord::Associations::CollectionProxy.prepend(
Module.new do
def count
def count(column_name = nil)
if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
Bullet::Detector::CounterCache.add_counter_cache(
proxy_association.owner,
proxy_association.reflection.name
)
end
super
super(column_name)
end
end
)
Expand Down
4 changes: 2 additions & 2 deletions lib/bullet/active_record71.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ def count_records

::ActiveRecord::Associations::CollectionProxy.prepend(
Module.new do
def count
def count(column_name = nil)
if Bullet.start? && !proxy_association.is_a?(::ActiveRecord::Associations::ThroughAssociation)
Bullet::Detector::CounterCache.add_counter_cache(
proxy_association.owner,
proxy_association.reflection.name
)
end
super
super(column_name)
end
end
)
Expand Down

0 comments on commit 95ffb25

Please sign in to comment.