Parent

Methods

Class/Module Index [+]

Quicksearch

Mongoid::Persistence::Atomic::Inc

This class provides atomic $inc behaviour.

Public Instance Methods

persist() click to toggle source

Sends the atomic $inc operation to the database.

@example Persist the new values.

inc.persist

@return [ Object ] The new integer value.

@since 2.0.0

# File lib/mongoid/persistence/atomic/inc.rb, line 17
def persist
  prepare do
    current = document[field] || 0
    document[field] = current + value
    document[field].tap do
      collection.update(document.atomic_selector, operation("$inc"), options)
      document.remove_change(field)
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.