Sha256: 62683edb7dd0c45d9ed799cd0be2df2b2e4b3915e7106d590ddd2a278ced0e92
Contents?: true
Size: 795 Bytes
Versions: 14
Compression:
Stored size: 795 Bytes
Contents
# encoding: utf-8 require "mongoid/association/referenced/eager" module Mongoid module Association # This module defines the eager loading behavior for criteria. # # @since 7.0 module EagerLoadable def eager_loadable? !criteria.inclusions.empty? end def eager_load(docs) docs.tap do |d| if eager_loadable? preload(criteria.inclusions, d) end end end def preload(relations, docs) relations.group_by(&:inverse_class_name) .values .each do |associations| associations.group_by(&:relation) .each do |relation, association| relation.eager_loader(association, docs).run end end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems