123456789_123456789_123456789_123456789_123456789_

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

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Mongoid::Association::EagerLoad::AssociationInclusion
Defined in: lib/mongoid/association/eager_load/inclusion.rb

Overview

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.

Class Method Summary

AssociationInclusion - Inherited

.for

Builds the right kind of inclusion for the association.

.for?

Whether this kind handles the given association.

.new

Instance Attribute Summary

Instance Method Summary

Inclusion - Inherited

#contribute

Add this inclusion's stages to the destination.

Constructor Details

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

Class Method Details

.for?(association) ⇒ true | false

Parameters:

Returns:

  • (true | false)

    Whether the association is embedded.

[ GitHub ]

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

def for?(association)
  association.embedded?
end

Instance Method Details

#contribute(destination, chain)

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).

[ GitHub ]

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

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