Class: Mongoid::Relations::Builders::Referenced::In
- Inherits:
-
Mongoid::Relations::Builder
- Object
- Mongoid::Relations::Builder
- Mongoid::Relations::Builders::Referenced::In
- Defined in:
- lib/mongoid/relations/builders/referenced/in.rb
Instance Attribute Summary
Attributes inherited from Mongoid::Relations::Builder
Instance Method Summary collapse
-
#build(type = nil) ⇒ Document
This builder either takes a foreign key and queries for the object or a document, where it will just return it.
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 a foreign key and queries for the object or a document, where it will just return it.
17 18 19 20 21 22 23 24 |
# File 'lib/mongoid/relations/builders/referenced/in.rb', line 17 def build(type = nil) return object unless query? begin (type ? type.constantize : .klass).find(object) rescue Errors::DocumentNotFound return nil end end |