module Sequel::Plugins::TacticalEagerLoading::DatasetMethods

Private Instance Methods

_eager_graph_build_associations(_, egl) click to toggle source

Set the retrieved_with and retrieved_by attributes for each of the associated objects created by the eager graph loader with the appropriate class dataset and array of objects.

Calls superclass method
# File lib/sequel/plugins/tactical_eager_loading.rb, line 166
def _eager_graph_build_associations(_, egl)
  objects = super

  master = egl.master
  egl.records_map.each do |k, v|
    next if k == master || v.empty?

    by = opts[:graph][:table_aliases][k]
    values = v.values

    values.each do |o|
      next unless o.is_a?(TacticalEagerLoading::InstanceMethods) && !o.retrieved_by
      o.retrieved_by = by
      o.retrieved_with = values
    end
  end

  objects
end
post_load(objects) click to toggle source

Set the retrieved_with and retrieved_by attributes for each object with the current dataset and array of all objects.

Calls superclass method
# File lib/sequel/plugins/tactical_eager_loading.rb, line 188
def post_load(objects)
  super
  objects.each do |o|
    next unless o.is_a?(Sequel::Model)
    o.retrieved_by = self
    o.retrieved_with = objects
  end
end