Class: Mongoid::Association::Referenced::HasOne::Eager
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
Mongoid::Association::Eager
|
Defined in: | lib/mongoid/association/referenced/has_one/eager.rb |
Overview
Eager
class for has_one associations.
Class Method Summary
::Mongoid::Association::Eager
- Inherited
.new | Instantiate the eager load class. |
Instance Method Summary
- #group_by_key private
- #key private
- #preload private
::Mongoid::Association::Eager
- Inherited
#run | Run the preloader. |
#each_loaded_document_of_class | Retrieves the documents of the specified class, that have the foreign key included in the specified list of keys. |
#shift_association | Shift the current association metadata. |
Constructor Details
This class inherits a constructor from Mongoid::Association::Eager
Instance Method Details
#group_by_key (private)
[ GitHub ]# File 'lib/mongoid/association/referenced/has_one/eager.rb', line 24
def group_by_key @association.primary_key end
#key (private)
[ GitHub ]# File 'lib/mongoid/association/referenced/has_one/eager.rb', line 28
def key @association.foreign_key end
#preload (private)
[ GitHub ]# File 'lib/mongoid/association/referenced/has_one/eager.rb', line 13
def preload @docs.each do |d| set_relation(d, nil) end each_loaded_document do |doc| id = doc.send(key) set_on_parent(id, doc) end end