Class: Mongoid::Associations::BelongsToAssociation
- Includes:
- Decorator
- Defined in:
- lib/mongoid/associations/belongs_to_association.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#find(id) ⇒ Object
Returns the parent document.
-
#initialize(document) ⇒ BelongsToAssociation
constructor
Creates the new association by setting the internal document as the passed in Document.
Methods included from Decorator
Constructor Details
#initialize(document) ⇒ BelongsToAssociation
Creates the new association by setting the internal document as the passed in Document. This should be the parent.
All method calls on this object will then be delegated to the internal document itself.
12 13 14 15 |
# File 'lib/mongoid/associations/belongs_to_association.rb', line 12 def initialize(document) @document = document.parent decorate! end |
Instance Method Details
#find(id) ⇒ Object
Returns the parent document. The id param is present for compatibility with rails, however this could be overwritten in the future.
20 21 22 |
# File 'lib/mongoid/associations/belongs_to_association.rb', line 20 def find(id) @document end |