Class: Mongoid::Persistence::Atomic::Inc
- Inherits:
-
Object
- Object
- Mongoid::Persistence::Atomic::Inc
- Includes:
- Operation
- Defined in:
- lib/mongoid/persistence/atomic/inc.rb
Overview
This class provides atomic $inc behaviour.
Instance Attribute Summary
Attributes included from Operation
#document, #fields, #options, #value
Instance Method Summary collapse
-
#persist ⇒ Object
Sends the atomic $inc operation to the database.
Methods included from Operation
#collection, #initialize, #operation, #path, #prepare
Methods included from Atomic::Positionable
Instance Method Details
#persist ⇒ Object
Sends the atomic $inc operation to the database.
18 19 20 21 22 23 24 25 |
# File 'lib/mongoid/persistence/atomic/inc.rb', line 18 def persist prepare do current = document[field] || 0 document[field] = current + value execute("$inc") document[field] end end |