Method: Mongoid::Relations::Referenced::Many#initialize

Defined in:
lib/mongoid/relations/referenced/many.rb

#initialize(base, target, metadata) ⇒ Many

Instantiate a new references_many relation. Will set the foreign key and the base on the inverse object.

Examples:

Create the new relation.

Referenced::Many.new(base, target, )

Parameters:

  • base (Document)

    The document this relation hangs off of.

  • target (Array<Document>)

    The target of the relation.

  • metadata (Metadata)

    The relation’s metadata.

Since:

  • 2.0.0.beta.1



238
239
240
241
242
# File 'lib/mongoid/relations/referenced/many.rb', line 238

def initialize(base, target, )
  init(base, Targets::Enumerable.new(target), ) do
    raise_mixed if klass.embedded?
  end
end