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
187 def _eager_graph_build_associations(_, egl)
188   objects = super
189 
190   master = egl.master
191   egl.records_map.each do |k, v|
192     next if k == master || v.empty?
193 
194     by = opts[:graph][:table_aliases][k]
195     values = v.values
196 
197     values.each do |o|
198       next unless o.is_a?(TacticalEagerLoading::InstanceMethods) && !o.retrieved_by
199       o.retrieved_by = by
200       o.retrieved_with = values
201     end
202   end
203 
204   objects
205 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
209 def post_load(objects)
210   super
211   objects.each do |o|
212     next unless o.is_a?(Sequel::Model)
213     o.retrieved_by = self
214     o.retrieved_with = objects
215   end
216 end