Module: EagerRecord::EagerPreloading::AssociationCollectionExtensions
- Defined in:
- lib/eager_record/eager_preloading.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
63 64 65 66 67 |
# File 'lib/eager_record/eager_preloading.rb', line 63 def self.included(base) base.module_eval do alias_method_chain :load_target, :eager_preloading end end |
Instance Method Details
#load_target_with_eager_preloading ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/eager_record/eager_preloading.rb', line 69 def load_target_with_eager_preloading if @reflection.[:conditions].nil? && (!@owner.new_record? || foreign_key_present) if !loaded? if originating_collection = @owner.instance_variable_get(:@originating_collection) @owner.class.__send__(:preload_associations, originating_collection, @reflection.name) return target if loaded? end end end load_target_without_eager_preloading end |