Class: Bullet::Detector::Association
- Defined in:
- lib/bullet/detector/association.rb
Direct Known Subclasses
Class Method Summary collapse
- .add_call_object_associations(object, associations) ⇒ Object
- .add_object_associations(object, associations) ⇒ Object
- 
  
    
      .impossible_objects  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    impossible_objects keep the class to objects relationships that the objects may not cause N+1 query. 
- 
  
    
      .possible_objects  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    possible_objects keep the class to object relationships that the objects may cause N+1 query. 
Class Method Details
.add_call_object_associations(object, associations) ⇒ Object
| 22 23 24 25 26 27 28 29 30 31 32 33 | # File 'lib/bullet/detector/association.rb', line 22 def add_call_object_associations(object, associations) return unless Bullet.start? return if !Bullet.n_plus_one_query_enable? && !Bullet.unused_eager_loading_enable? return unless object.bullet_primary_key_value Bullet.debug( 'Detector::Association#add_call_object_associations', "object: #{object.bullet_key}, associations: #{associations}" ) call_stacks.add(object.bullet_key) call_object_associations.add(object.bullet_key, associations) end | 
.add_object_associations(object, associations) ⇒ Object
| 9 10 11 12 13 14 15 16 17 18 19 20 | # File 'lib/bullet/detector/association.rb', line 9 def add_object_associations(object, associations) return unless Bullet.start? return if !Bullet.n_plus_one_query_enable? && !Bullet.unused_eager_loading_enable? return unless object.bullet_primary_key_value Bullet.debug( 'Detector::Association#add_object_associations', "object: #{object.bullet_key}, associations: #{associations}" ) call_stacks.add(object.bullet_key) object_associations.add(object.bullet_key, associations) end | 
.impossible_objects ⇒ Object
impossible_objects keep the class to objects relationships that the objects may not cause N+1 query. e.g. { Post => [“Post:1”, “Post:2”] } if find collection returns only one object, then the object is impossible object, impossible_objects are used to avoid treating 1+1 query to N+1 query.
| 47 48 49 | # File 'lib/bullet/detector/association.rb', line 47 def impossible_objects Thread.current.thread_variable_get(:bullet_impossible_objects) end | 
.possible_objects ⇒ Object
possible_objects keep the class to object relationships that the objects may cause N+1 query. e.g. { Post => [“Post:1”, “Post:2”] }
| 38 39 40 | # File 'lib/bullet/detector/association.rb', line 38 def possible_objects Thread.current.thread_variable_get(:bullet_possible_objects) end |