mongoid/mongoid — pull request #3006 by tomglue (2013-04-29 16:01:01+00:00)
Title: store result on Update operation

Hi there,

This patch allows access to the most recent Mongoid::Persistence::Operations::Update by adding a last_update attr_reader to Mongoid::Persistence.

We are also storing the the result of the update operation on the Update object in order to extract information from getlasterror (when running safely).

The specific reason behind wanting to do this is to be able to access the updateExisting information from getlasterror in the mongoid_optimistic_locking gem (https://github.com/burgalon/mongoid_optimistic_locking). Here is an example of how the patch can be used in it:

https://gist.github.com/tomglue/5482520#file-gistfile1-rb-L10

I appreciate that this may not be the correct or best way to achieve this, but was looking to get some feedback on the solution I have come up with.

Cheers