Class: Mongoid::Relations::Builders::Referenced::One
- Inherits:
-
Mongoid::Relations::Builder
- Object
- Mongoid::Relations::Builder
- Mongoid::Relations::Builders::Referenced::One
- Defined in:
- lib/mongoid/relations/builders/referenced/one.rb
Overview
Instance Attribute Summary
Attributes inherited from Mongoid::Relations::Builder
Instance Method Summary collapse
-
#build(type = nil) ⇒ Document
This builder either takes an _id or an object and queries for the inverse side using the id or sets the object.
Methods inherited from Mongoid::Relations::Builder
Constructor Details
This class inherits a constructor from Mongoid::Relations::Builder
Instance Method Details
#build(type = nil) ⇒ Document
This builder either takes an _id or an object and queries for the inverse side using the id or sets the object.
17 18 19 20 21 |
# File 'lib/mongoid/relations/builders/referenced/one.rb', line 17 def build(type = nil) return object unless query? return nil if base.new_record? .criteria(Conversions.flag(object, ), base.class).from_map_or_db end |