Sha256: 637e93b71d54e5ccd9436927a281c1bcc7d79392abeaaf7c03ef72befe5ed1d8
Contents?: true
Size: 794 Bytes
Versions: 5
Compression:
Stored size: 794 Bytes
Contents
# encoding: utf-8 module Mongoid #:nodoc: module Persistence #:nodoc: module Atomic #:nodoc: # This class provides the ability to perform an explicit $push modification # on a specific field. class Push < Operation # 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 def persist document[field] = [] unless document[field] document.send(field).push(value).tap do |value| document.collection.update(document._selector, operation("$push"), options) document.changes.delete(field.to_s) end end end end end end
Version data entries
5 entries across 5 versions & 2 rubygems