lib/bullet/mongoid3.rb in bullet-4.1.3 vs lib/bullet/mongoid3.rb in bullet-4.1.4
- old
+ new
@@ -8,16 +8,16 @@
alias_method :origin_each, :each
alias_method :origin_eager_load, :eager_load
def first
result = origin_first
- Bullet::Detector::Association.add_impossible_object(result)
+ Bullet::Detector::Association.add_impossible_object(result) if result
result
end
def last
result = origin_last
- Bullet::Detector::Association.add_impossible_object(result)
+ Bullet::Detector::Association.add_impossible_object(result) if result
result
end
def each(&block)
records = query.map{ |doc| ::Mongoid::Factory.from_db(klass, doc) }