Module: Mongoid::Persistence::Atomic
- Included in:
- Mongoid::Persistence
- Defined in:
- lib/mongoid/persistence/atomic.rb,
lib/mongoid/persistence/atomic/bit.rb,
lib/mongoid/persistence/atomic/inc.rb,
lib/mongoid/persistence/atomic/pop.rb,
lib/mongoid/persistence/atomic/pull.rb,
lib/mongoid/persistence/atomic/push.rb,
lib/mongoid/persistence/atomic/sets.rb,
lib/mongoid/persistence/atomic/unset.rb,
lib/mongoid/persistence/atomic/rename.rb,
lib/mongoid/persistence/atomic/pull_all.rb,
lib/mongoid/persistence/atomic/push_all.rb,
lib/mongoid/persistence/atomic/operation.rb,
lib/mongoid/persistence/atomic/add_to_set.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Operation Classes: AddToSet, Bit, Inc, Pop, Pull, PullAll, Push, PushAll, Rename, Sets, Unset
Instance Method Summary collapse
-
#add_to_set(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $addToSet of the provided value on the supplied field.
-
#bit(field, value, options = {}) ⇒ Integer
Performs an atomic $bit operation on the field with the provided hash of bitwise ops to execute in order.
-
#inc(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $inc of the provided value on the supplied field.
-
#pop(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $pop of the provided value on the supplied field.
-
#pull(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $pull 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.
-
#push_all(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $pushAll of the provided value on the supplied field.
-
#rename(field, value, options = {}) ⇒ Object
Performs the atomic $rename from the old field to the new field name.
-
#set(field, value = nil, options = {}) ⇒ Array<Object>
Performs an atomic $set of the provided value on the supplied field.
-
#unset(field, options = {}) ⇒ nil
Performs the atomic $unset 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.
37 38 39 |
# File 'lib/mongoid/persistence/atomic.rb', line 37 def add_to_set(field, value, = {}) AddToSet.new(self, field, value, ).persist end |
#bit(field, value, options = {}) ⇒ Integer
Performs an atomic $bit operation on the field with the provided hash of bitwise ops to execute in order.
60 61 62 |
# File 'lib/mongoid/persistence/atomic.rb', line 60 def bit(field, value, = {}) Bit.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.
78 79 80 |
# File 'lib/mongoid/persistence/atomic.rb', line 78 def inc(field, value, = {}) Inc.new(self, field, value, ).persist end |
#pop(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $pop of the provided value on the supplied field.
98 99 100 |
# File 'lib/mongoid/persistence/atomic.rb', line 98 def pop(field, value, = {}) Pop.new(self, field, value, ).persist end |
#pull(field, value, options = {}) ⇒ Array<Object>
Support for a $pull with an expression is not yet supported.
Performs an atomic $pull of the provided value on the supplied field.
117 118 119 |
# File 'lib/mongoid/persistence/atomic.rb', line 117 def pull(field, value, = {}) Pull.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.
135 136 137 |
# File 'lib/mongoid/persistence/atomic.rb', line 135 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.
152 153 154 |
# File 'lib/mongoid/persistence/atomic.rb', line 152 def push(field, value, = {}) Push.new(self, field, value, ).persist end |
#push_all(field, value, options = {}) ⇒ Array<Object>
Performs an atomic $pushAll of the provided value on the supplied field. If the field does not exist it will be initialized as an empty array.
169 170 171 |
# File 'lib/mongoid/persistence/atomic.rb', line 169 def push_all(field, value, = {}) PushAll.new(self, field, value, ).persist end |
#rename(field, value, options = {}) ⇒ Object
Performs the atomic $rename from the old field to the new field name.
185 186 187 |
# File 'lib/mongoid/persistence/atomic.rb', line 185 def rename(field, value, = {}) Rename.new(self, field, value, ).persist end |
#set(field, value = nil, options = {}) ⇒ Array<Object>
Performs an atomic $set of the provided value on the supplied field. If the field does not exist it will be initialized as the provided value.
203 204 205 |
# File 'lib/mongoid/persistence/atomic.rb', line 203 def set(field, value = nil, = {}) Sets.new(self, field, value, ).persist end |