Module: Goldiloader::RelationPatch

Defined in:
lib/goldiloader/active_record_patches.rb

Instance Method Summary collapse

Instance Method Details

#auto_include(auto_include = true) ⇒ Object



45
46
47
# File 'lib/goldiloader/active_record_patches.rb', line 45

def auto_include(auto_include = true)
  spawn.auto_include!(auto_include)
end

#auto_include!(auto_include = true) ⇒ Object



49
50
51
52
# File 'lib/goldiloader/active_record_patches.rb', line 49

def auto_include!(auto_include = true)
  self.auto_include_value = auto_include
  self
end

#auto_include_valueObject



54
55
56
# File 'lib/goldiloader/active_record_patches.rb', line 54

def auto_include_value
  @values.fetch(:auto_include, true)
end

#auto_include_value=(value) ⇒ Object



58
59
60
61
# File 'lib/goldiloader/active_record_patches.rb', line 58

def auto_include_value=(value)
  assert_mutability!
  @values[:auto_include] = value
end

#exec_queriesObject



37
38
39
40
41
42
43
# File 'lib/goldiloader/active_record_patches.rb', line 37

def exec_queries
  return super if loaded? || !auto_include_value

  models = super
  Goldiloader::AutoIncludeContext.register_models(models, eager_load_values)
  models
end