Class: Mongoid::Association::One
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Proxy ,
Forwardable
|
|
Instance Chain:
|
|
Inherits: |
Mongoid::Association::Proxy
|
Defined in: | lib/mongoid/association/one.rb |
Overview
This is the superclass for one to one relations and defines the common behavior or those proxies.
Constant Summary
Proxy
- Inherited
Class Method Summary
Proxy
- Inherited
.apply_ordering | Apply ordering to the criteria if it was defined on the association. |
.new | Sets the target and the association metadata properties. |
Instance Attribute Summary
Proxy
- Inherited
#_association, | |
#_base | Model instance for the base of the association. |
#_target | Model instance for one to one associations, or array of model instances for one to many associations, for the target of the association. |
::Mongoid::Threaded::Lifecycle
- Included
#_assigning | Begin the assignment of attributes. |
#_assigning? | Is the current thread in assigning mode? |
#_binding | Execute a block in binding mode. |
#_binding? | Is the current thread in binding mode? |
#_building | Execute a block in building mode. |
#_building? | Is the current thread in building mode? |
#_creating? | Is the current thread in creating mode? |
#_loading | Execute a block in loading mode. |
#_loading? | Is the current thread in loading mode? |
Instance Method Summary
-
#__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.
Proxy
- Inherited
#extend_proxies | Allow extension to be an array and extend each module. |
#extend_proxy, | |
#klass | Get the class from the association, or return nil if no association present. |
#reset_unloaded | Resets the criteria inside the association proxy. |
#substitutable | The default substitutable object for an association proxy is the clone of the target. |
Marshalable
- Included
#marshal_dump | Provides the data needed to Marshal.dump an association proxy. |
#marshal_load | Takes the provided data and sets it back on the proxy. |
Constructor Details
This class inherits a constructor from Mongoid::Association::Proxy
Instance Method Details
#__evolve_object_id__ ⇒ Object
Evolve the proxy document into an object id.
# File 'lib/mongoid/association/one.rb', line 49
def __evolve_object_id__ _target._id end
#clear ⇒ true
| false
Clear this relation - same as calling #delete on the document.
# File 'lib/mongoid/association/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.
# File 'lib/mongoid/association/one.rb', line 27
def in_memory [ _target ] end
#respond_to?(name, include_private = false) ⇒ true
| false
Since method_missing is overridden we should override this as well.
# File 'lib/mongoid/association/one.rb', line 39
def respond_to?(name, include_private = false) _target.respond_to?(name, include_private) || super end