Method: Mongoid::Relations::Accessors#set_relation

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

#set_relation(name, relation) ⇒ Proxy

Set the supplied relation 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 relation.

  • relation (Proxy)

    The relation to set.

Returns:

  • (Proxy)

    The relation.

Since:

  • 2.0.0.rc.1



74
75
76
# File 'lib/mongoid/relations/accessors.rb', line 74

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