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
166 def _eager_graph_build_associations(_, egl)
167   objects = super
168 
169   master = egl.master
170   egl.records_map.each do |k, v|
171     next if k == master || v.empty?
172 
173     by = opts[:graph][:table_aliases][k]
174     values = v.values
175 
176     values.each do |o|
177       next unless o.is_a?(TacticalEagerLoading::InstanceMethods) && !o.retrieved_by
178       o.retrieved_by = by
179       o.retrieved_with = values
180     end
181   end
182 
183   objects
184 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
188 def post_load(objects)
189   super
190   objects.each do |o|
191     next unless o.is_a?(Sequel::Model)
192     o.retrieved_by = self
193     o.retrieved_with = objects
194   end
195 end