Module: OccamsRecord::EagerLoaders

Defined in:
lib/occams-record/eager_loaders/eager_loaders.rb,
lib/occams-record/eager_loaders/base.rb,
lib/occams-record/eager_loaders/habtm.rb,
lib/occams-record/eager_loaders/tracer.rb,
lib/occams-record/eager_loaders/builder.rb,
lib/occams-record/eager_loaders/context.rb,
lib/occams-record/eager_loaders/has_one.rb,
lib/occams-record/eager_loaders/through.rb,
lib/occams-record/eager_loaders/has_many.rb,
lib/occams-record/eager_loaders/ad_hoc_one.rb,
lib/occams-record/eager_loaders/belongs_to.rb,
lib/occams-record/eager_loaders/ad_hoc_base.rb,
lib/occams-record/eager_loaders/ad_hoc_many.rb,
lib/occams-record/eager_loaders/polymorphic_belongs_to.rb

Overview

Contains eager loaders for various kinds of associations.

Defined Under Namespace

Modules: Builder Classes: AdHocBase, AdHocMany, AdHocOne, Base, BelongsTo, Context, Habtm, HasMany, HasOne, PolymorphicBelongsTo, Through, Tracer

Class Method Summary collapse

Class Method Details

.fetch!(ref) ⇒ Object

Fetch the appropriate eager loader for the given association type.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/occams-record/eager_loaders/eager_loaders.rb', line 23

def self.fetch!(ref)
  case ref.macro
  when :belongs_to
    ref.polymorphic? ? PolymorphicBelongsTo : BelongsTo
  when :has_one
    HasOne
  when :has_many
    HasMany
  when :has_and_belongs_to_many
    Habtm
  else
    raise "Unsupported association type `#{macro}`"
  end
end