Class: Mongoid::Association::EagerLoad::InclusionTree Private
- Inherits:
-
Object
- Object
- Mongoid::Association::EagerLoad::InclusionTree
- Defined in:
- lib/mongoid/association/eager_load/inclusion_tree.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The tree of nested inclusions an eager load asks to load. Built from the criteria's inclusions, it contributes each root node's stages to the pipeline, with each node already carrying its own children.
Each root branch is built from its own copy of the inclusions, and an inclusion is removed as it is placed, so it lands once per branch even if more than one parent in that branch points at it, and a circular chain of inclusions can't loop forever.
Class Method Summary collapse
-
.from(inclusions, pipeline) ⇒ InclusionTree
private
Builds the tree for the criteria's inclusions.
Instance Method Summary collapse
-
#contribute_to(destination) ⇒ Object
private
Contribute each root inclusion's stages to the pipeline.
-
#initialize(inclusions, pipeline, by_name) ⇒ InclusionTree
constructor
private
A new instance of InclusionTree.
Constructor Details
#initialize(inclusions, pipeline, by_name) ⇒ InclusionTree
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of InclusionTree.
34 35 36 37 38 |
# File 'lib/mongoid/association/eager_load/inclusion_tree.rb', line 34 def initialize(inclusions, pipeline, by_name) @inclusions = inclusions @pipeline = pipeline @by_name = by_name end |
Class Method Details
.from(inclusions, pipeline) ⇒ InclusionTree
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Builds the tree for the criteria's inclusions.
27 28 29 |
# File 'lib/mongoid/association/eager_load/inclusion_tree.rb', line 27 def from(inclusions, pipeline) new(inclusions, pipeline, inclusions.to_h { |association| [ association.name, association ] }) end |
Instance Method Details
#contribute_to(destination) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Contribute each root inclusion's stages to the pipeline. Each root carries its own children, so the whole tree is appended by recursion from the roots downward.
45 46 47 |
# File 'lib/mongoid/association/eager_load/inclusion_tree.rb', line 45 def contribute_to(destination) roots.each { |root| root.contribute(destination, []) } end |