class Mongoid::Persistence::Atomic::Pop

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

Public Instance Methods

persist() click to toggle source

Sends the atomic $pop operation to the database.

@example Persist the new values.

pop.persist

@return [ Object ] The new array value.

@since 2.1.0

# File lib/mongoid/persistence/atomic/pop.rb, line 18
def persist
  prepare do
    if document[field]
      values = document.send(field)
      value > 0 ? values.pop : values.shift
      execute("$pop")
      values
    end
  end
end