Module: Mongoid::Persistence::Atomic
- Included in:
- Mongoid::Persistence
- Defined in:
- lib/mongoid/persistence/atomic.rb,
lib/mongoid/persistence/atomic/inc.rb,
lib/mongoid/persistence/atomic/push.rb,
lib/mongoid/persistence/atomic/pull_all.rb,
lib/mongoid/persistence/atomic/operation.rb,
lib/mongoid/persistence/atomic/add_to_set.rb
Overview
:nodoc:
Defined Under Namespace
Classes: AddToSet, Inc, Operation, PullAll, Push
Instance Method Summary collapse
-
#add_to_set(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $addToSet of the provided value on the supplied field.
-
#inc(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $inc of the provided value on the supplied field.
-
#pull_all(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $pullAll of the provided value on the supplied field.
-
#push(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $push of the provided value on the supplied field.
Instance Method Details
#add_to_set(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $addToSet of the provided value on the supplied field. If the field does not exist it will be initialized as an empty array.
If the value already exists on the array it will not be added.
30 31 32 |
# File 'lib/mongoid/persistence/atomic.rb', line 30 def add_to_set(field, value, = {}) AddToSet.new(self, field, value, ).persist end |
#inc(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $inc of the provided value on the supplied field. If the field does not exist it will be initialized as the provided value.
48 49 50 |
# File 'lib/mongoid/persistence/atomic.rb', line 48 def inc(field, value, = {}) Inc.new(self, field, value, ).persist end |
#pull_all(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $pullAll of the provided value on the supplied field. If the field does not exist it will be initialized as an empty array.
66 67 68 |
# File 'lib/mongoid/persistence/atomic.rb', line 66 def pull_all(field, value, = {}) PullAll.new(self, field, value, ).persist end |
#push(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $push of the provided value on the supplied field. If the field does not exist it will be initialized as an empty array.
83 84 85 |
# File 'lib/mongoid/persistence/atomic.rb', line 83 def push(field, value, = {}) Push.new(self, field, value, ).persist end |