Class: Bullet::Detector::UnusedEagerAssociation

Inherits:
Association show all
Defined in:
lib/bullet/detector/unused_eager_association.rb

Class Method Summary collapse

Methods inherited from Association

add_call_object_associations, add_eager_loadings, add_impossible_object, add_object_associations, add_possible_objects, clear, start_request

Methods inherited from Base

end_request, start_request

Class Method Details

.check_unused_preload_associationsObject

check if there are unused preload associations. for each object => association

get related_objects from eager_loadings associated with object and associations
get call_object_association from associations of call_object_associations whose object is in related_objects 
if association not in call_object_association, then the object => association - call_object_association is ununsed preload assocations


9
10
11
12
13
14
15
16
17
# File 'lib/bullet/detector/unused_eager_association.rb', line 9

def self.check_unused_preload_associations
  @@checked = true
  object_associations.each do |object, association|
    object_association_diff = diff_object_association object, association
    next if object_association_diff.empty?

    create_notification object.class, object_association_diff
  end
end