Class: Mongoid::Association::EagerLoad::AssociationInclusion Private

Inherits:
Inclusion
  • Object
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 inclusion that stands for a single association. The LookupPipeline holds the stage-building helpers the kinds lean on, and a node carries its own children, so the pipeline is built by recursion from the roots downward.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Inclusion

#contribute

Constructor Details

#initialize(association, pipeline, children) ⇒ AssociationInclusion

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



57
58
59
60
61
62
# File 'lib/mongoid/association/eager_load/inclusion.rb', line 57

def initialize(association, pipeline, children)
  super()
  @association = association
  @pipeline = pipeline
  @children = children
end

Instance Attribute Details

#associationMongoid::Association::Relatable (readonly)

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 The association this stands for.

Returns:



55
56
57
# File 'lib/mongoid/association/eager_load/inclusion.rb', line 55

def association
  @association
end

Class Method Details

.for(association, pipeline, children) ⇒ AssociationInclusion

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 right kind of inclusion for the association. Each subclass decides whether it handles it (.for?); exactly one does.

Parameters:

Returns:



40
41
42
# File 'lib/mongoid/association/eager_load/inclusion.rb', line 40

def for(association, pipeline, children)
  subclasses.find { |kind| kind.for?(association) }.new(association, pipeline, children)
end

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

Whether this kind handles the given association.

Parameters:

Returns:

  • (true | false)

    Whether it handles it.

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/mongoid/association/eager_load/inclusion.rb', line 49

def for?(association)
  raise NotImplementedError
end