Class: Mongoid::Associations::BelongsToAssociation
- Defined in:
- lib/mongoid/associations/belongs_to_association.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(document) ⇒ BelongsToAssociation
constructor
Creates the new association by setting the internal document as the passed in Document.
-
#method_missing(method, *args) ⇒ Object
All calls to this association will be delegated straight to the encapsulated document.
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.
11 12 13 |
# File 'lib/mongoid/associations/belongs_to_association.rb', line 11 def initialize(document) @document = document.parent end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
All calls to this association will be delegated straight to the encapsulated document.
17 18 19 |
# File 'lib/mongoid/associations/belongs_to_association.rb', line 17 def method_missing(method, *args) @document.send(method, *args) end |