Class: Mongoid::Associations::BelongsToAssociation

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid/associations/belongs_to_association.rb

Overview

:nodoc:

Instance Method Summary collapse

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