Class: Mongoid::Association::EagerLoad::EmbeddedInclusion Private

Inherits:
AssociationInclusion show all
Defined in:
lib/mongoid/association/eager_load/inclusion.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.

An embedded inclusion: it rides inside its own document, so it adds no stage of its own. Its children contribute to the same destination, with this document appended to their embedded path.

For Computer.eager_load(port: :device) the :port inclusion emits nothing; it hands the path [ :port ] to :device, which EmbeddedDistributor then turns into stages.

Instance Attribute Summary

Attributes inherited from AssociationInclusion

#association

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AssociationInclusion

for, #initialize

Constructor Details

This class inherits a constructor from Mongoid::Association::EagerLoad::AssociationInclusion

Class Method Details

.for?(association) ⇒ true | false

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 Whether the association is embedded.

Parameters:

Returns:

  • (true | false)

    Whether the association is embedded.



132
133
134
# File 'lib/mongoid/association/eager_load/inclusion.rb', line 132

def for?(association)
  association.embedded?
end

Instance Method Details

#contribute(destination, chain) ⇒ 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.

Add no stage of its own; hand this document down the embedded path so the children distribute onto it.

Parameters:

  • destination (Array<Hash>)

    The pipeline (or sub-pipeline) the stages are appended to.

  • chain (Array<Mongoid::Association::Relatable>)

    The embedded path accumulated from the ancestors above this inclusion (empty at the top).



144
145
146
# File 'lib/mongoid/association/eager_load/inclusion.rb', line 144

def contribute(destination, chain)
  @children.each { |child| child.contribute(destination, chain + [ @association ]) }
end