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 numeric 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
    execute("$inc")
    document[field]
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.