Method: Mongoid::Relations::Builders::NestedAttributes::Many#initialize

Defined in:
lib/mongoid/relations/builders/nested_attributes/many.rb

#initialize(metadata, attributes, options = {}) ⇒ Many

Create the new builder for nested attributes on one-to-many relations.

Examples:

Initialize the builder.

One.new(, attributes, options)

Parameters:

  • metadata (Metadata)

    The relation metadata.

  • attributes (Hash)

    The attributes hash to attempt to set.

  • options (Hash) (defaults to: {})

    The options defined.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mongoid/relations/builders/nested_attributes/many.rb', line 44

def initialize(, attributes, options = {})
  if attributes.respond_to?(:with_indifferent_access)
    @attributes = attributes.with_indifferent_access.sort do |a, b|
      a[0].to_i <=> b[0].to_i
    end
  else
    @attributes = attributes
  end
   = 
  @options = options
end