Parent

Methods

Class/Module Index [+]

Quicksearch

Mongoid::Persistence::Atomic::Push

This class provides the ability to perform an explicit $push modification on a specific field.

Public Instance Methods

persist() click to toggle source

Sends the atomic $push operation to the database.

@example Persist the new values.

push.persist

@return [ Object ] The new array value.

@since 2.0.0

# File lib/mongoid/persistence/atomic/push.rb, line 18
def persist
  prepare do
    document[field] = [] unless document[field]
    document.send(field).push(value).tap do |value|
      collection.update(document.atomic_selector, operation("$push"), options)
      document.remove_change(field)
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.