lib/bullet/mongoid7x.rb in bullet-6.0.2 vs lib/bullet/mongoid7x.rb in bullet-6.1.0
- old
+ new
@@ -35,25 +35,21 @@
records.each(&block)
end
def eager_load(docs)
associations = criteria.inclusions.map(&:name)
- docs.each do |doc|
- Bullet::Detector::NPlusOneQuery.add_object_associations(doc, associations)
- end
+ docs.each { |doc| Bullet::Detector::NPlusOneQuery.add_object_associations(doc, associations) }
Bullet::Detector::UnusedEagerLoading.add_eager_loadings(docs, associations)
origin_eager_load(docs)
end
end
::Mongoid::Association::Accessors.class_eval do
alias_method :origin_get_relation, :get_relation
def get_relation(name, association, object, reload = false)
result = origin_get_relation(name, association, object, reload)
- unless association.embedded?
- Bullet::Detector::NPlusOneQuery.call_association(self, name)
- end
+ Bullet::Detector::NPlusOneQuery.call_association(self, name) unless association.embedded?
result
end
end
end
end