Class: Mongoid::Relations::Eager::HasOne
- Inherits:
-
Base
- Object
- Base
- Mongoid::Relations::Eager::HasOne
show all
- Defined in:
- build/mongoid-6.1/lib/mongoid/relations/eager/has_one.rb
Instance Method Summary
collapse
Methods inherited from Base
#each_loaded_document, #grouped_docs, #initialize, #keys_from_docs, #run, #set_on_parent, #shift_metadata
Instance Method Details
#group_by_key ⇒ Object
19
20
21
|
# File 'build/mongoid-6.1/lib/mongoid/relations/eager/has_one.rb', line 19
def group_by_key
@metadata.primary_key
end
|
#key ⇒ Object
23
24
25
|
# File 'build/mongoid-6.1/lib/mongoid/relations/eager/has_one.rb', line 23
def key
@metadata.foreign_key
end
|
#preload ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'build/mongoid-6.1/lib/mongoid/relations/eager/has_one.rb', line 8
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
|