Class: Mongoid::Relations::One
- Defined in:
- lib/mongoid/relations/one.rb
Overview
This is the superclass for one to one relations and defines the common behaviour or those proxies.
Direct Known Subclasses
Embedded::In, Embedded::One, Referenced::In, Referenced::One
Instance Attribute Summary
Attributes inherited from Proxy
#base, #loaded, #metadata, #target
Instance Method Summary collapse
-
#__evolve_object_id__ ⇒ Object
Evolve the proxy document into an object id.
-
#clear ⇒ true, false
Clear this relation - same as calling #delete on the document.
-
#in_memory ⇒ Array<Document>
Get all the documents in the relation that are loaded into memory.
-
#respond_to?(name, include_private = false) ⇒ true, false
Since method_missing is overridden we should override this as well.
Methods inherited from Proxy
apply_ordering, eager_load_ids, #init, #klass, #reset_unloaded, #substitutable, #with
Methods included from Marshalable
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Mongoid::Relations::Proxy
Instance Method Details
#__evolve_object_id__ ⇒ Object
Evolve the proxy document into an object id.
55 56 57 |
# File 'lib/mongoid/relations/one.rb', line 55 def __evolve_object_id__ target.id end |
#clear ⇒ true, false
Clear this relation - same as calling #delete on the document.
17 18 19 |
# File 'lib/mongoid/relations/one.rb', line 17 def clear target.delete end |
#in_memory ⇒ Array<Document>
Get all the documents in the relation that are loaded into memory.
29 30 31 |
# File 'lib/mongoid/relations/one.rb', line 29 def in_memory [ target ] end |
#respond_to?(name, include_private = false) ⇒ true, false
Since method_missing is overridden we should override this as well.
43 44 45 |
# File 'lib/mongoid/relations/one.rb', line 43 def respond_to?(name, include_private = false) target.respond_to?(name, include_private) || super end |