class Bullet::Detector::Association

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/bullet/detector/association.rbs

class Bullet::Detector::Association < Bullet::Detector::Base
  def add_object_associations: ((User | UserTrade) object, Symbol associations) -> Set
  def call_stacks: () -> Bullet::Registry::CallStack
  def object_associations: () -> Bullet::Registry::Base
end

def add_call_object_associations(object, associations)

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

def add_object_associations(object, associations)

Experimental RBS support (using type sampling data from the type_fusion project).

def add_object_associations: ((User | UserTrade) object, Symbol associations) -> Set

This signature was generated using 8 samples from 1 application.

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

def call_object_associations

they are used to detect unused preload associations.
e.g. { "Post:1" => [:comments] }
that object.associations is called.
call_object_associations keep the object relationships
def call_object_associations
  Thread.current[:bullet_call_object_associations]
end

def call_stacks

Experimental RBS support (using type sampling data from the type_fusion project).

def call_stacks: () -> Bullet::Registry::CallStack

This signature was generated using 8 samples from 1 application.

e.g. { 'Object:111' => [SomeProject/app/controllers/...] }
cal_stacks keeps stacktraces where querie-objects were called from.
def call_stacks
  Thread.current[:bullet_call_stacks]
end

def eager_loadings

e.g. { ["Post:1", "Post:2"] => [:comments, :user] }
that the associations are preloaded by find :include.
eager_loadings keep the object relationships
def eager_loadings
  Thread.current[:bullet_eager_loadings]
end

def impossible_objects

impossible_objects are used to avoid treating 1+1 query to N+1 query.
if find collection returns only one object, then the object is impossible object,
e.g. { Post => ["Post:1", "Post:2"] }
that the objects may not cause N+1 query.
impossible_objects keep the class to objects relationships
def impossible_objects
  Thread.current[:bullet_impossible_objects]
end

def inversed_objects

e.g. { "Comment:1" => ["post"] }
that association is inversed.
inversed_objects keeps object relationships
def inversed_objects
  Thread.current[:bullet_inversed_objects]
end

def object_associations

Experimental RBS support (using type sampling data from the type_fusion project).

def object_associations: () -> Bullet::Registry::Base

This signature was generated using 9 samples from 1 application.

unpreload associations or unused preload associations.
the object_associations keep all associations that may be or may no be
e.g. { "Post:1" => [:comments] }
that the object has many associations.
object_associations keep the object relationships
def object_associations
  Thread.current[:bullet_object_associations]
end

def possible_objects

e.g. { Post => ["Post:1", "Post:2"] }
that the objects may cause N+1 query.
possible_objects keep the class to object relationships
def possible_objects
  Thread.current[:bullet_possible_objects]
end