Module: Mongoid::Includes::Association::Eager

Defined in:
lib/mongoid/includes/association/eager.rb

Overview

Internal: Patch to the base class for eager load preload functions, that interacts with the Mongoid::Includes::Inclusion as @medatada.

Instance Method Summary collapse

Instance Method Details

#each_loaded_documentObject

Internal: Performs eager load and iterates over the preloaded documents for the current relation.



11
12
13
14
15
16
17
18
19
# File 'lib/mongoid/includes/association/eager.rb', line 11

def each_loaded_document
  foreign_key_values = keys_from_docs

  return @association.klass.none if foreign_key_values.empty?

  @association.load_documents_for(key, foreign_key_values).each do |doc|
    yield doc
  end
end