module Sequel::Plugins::TacticalEagerLoading::InstanceMethods
Attributes
retrieved_by[RW]
The dataset that retrieved this object, set if the object was reteived via Sequel::Dataset#all.
retrieved_with[RW]
All model objects retrieved with this object, set if the object was reteived via Sequel::Dataset#all.
Public Instance Methods
marshallable!()
click to toggle source
Remove #retrieved_by and #retrieved_with when marshalling. #retrieved_by contains unmarshallable objects, and #retrieved_with can be very large and is not helpful without retrieved_by.
Calls superclass method
# File lib/sequel/plugins/tactical_eager_loading.rb, line 41 def marshallable! @retrieved_by = nil @retrieved_with = nil super end
Private Instance Methods
load_associated_objects(opts, reload=false)
click to toggle source
If there the association is not in the associations cache and the object was reteived via Sequel::Dataset#all, eagerly load the association for all model objects retrieved with the current object.
Calls superclass method
# File lib/sequel/plugins/tactical_eager_loading.rb, line 52 def load_associated_objects(opts, reload=false) name = opts[:name] if !associations.include?(name) && retrieved_by && !frozen? begin retrieved_by.send(:eager_load, retrieved_with.reject{|o| o.frozen?}, name=>{}) rescue Sequel::UndefinedAssociation # This can happen if class table inheritance is used and the association # is only defined in a subclass. This particular instance can use the # association, but it can't be eagerly loaded as the parent class doesn't # have access to the association, and that's the class doing the eager loading. nil end end super end