Method: Mongoid::Association::Accessors#set_relation

Defined in:
lib/mongoid/association/accessors.rb

#set_relation(name, relation) ⇒ Proxy

Set the supplied association to an instance variable on the class with the provided name. Used as a helper just for code cleanliness.

Examples:

Set the proxy on the document.

person.set(:addresses, addresses)

Parameters:

  • name (String | Symbol)

    The name of the association.

  • relation (Proxy)

    The association to set.

Returns:

  • (Proxy)

    The association.



89
90
91
# File 'lib/mongoid/association/accessors.rb', line 89

def set_relation(name, relation)
  instance_variable_set("@_#{name}", relation)
end