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