mongoid/mongoid — pull request #2604 by lucasas (2012-12-03 16:38:27+00:00)
Title: Solving "have conflicting mods in update" when change Array order with new embedded objects

When we need to change the order of one embedded Array, like the following code:

```ruby
person = Person.create
existing_address = person.addresses.create(street: "Oxford St")
new_address = person.addresses.build(street: "Oxford St")

person.addresses[0] = new_address
person.addresses[1] = existing_address
```

So, when I call `atomic_updates`, Mongoid is not considering conflicts:

```ruby
{
"$set" => {
"title" => "Sir",
"addresses.0.street" => "Bond St"
},
"$pushAll" => {
"addresses" => [{
"_id" => new_address.id,
"street" => "Another",
"locations" => [
"_id" => location.id,
"name" => "Home"
]
}]
}
}
```

The pull request consider $pullAll operation when Mongoid is generating $set operation.

Other option to resolve the problem is change the method `_children` to return new embedded objects on the final of Array.