Sha256: 16e36713684fa1feaf58e687fad14228dc558f0577b9e772a4c6aa4f45c8f794
Contents?: true
Size: 861 Bytes
Versions: 188
Compression:
Stored size: 861 Bytes
Contents
# encoding: utf-8 module Mongoid #:nodoc: module Persistence #:nodoc: module Atomic #:nodoc: # This class provides the ability to perform an explicit $pushAll modification # on a specific field. class PushAll include Operation # Sends the atomic $pushAll operation to the database. # # @example Persist the new values. # pushAll.persist # # @return [ Object ] The new array value. # # @since 2.1.0 def persist prepare do document[field] = [] unless document[field] document.send(field).concat(value).tap do |value| collection.update(document.atomic_selector, operation("$pushAll"), options) document.remove_change(field) end end end end end end end
Version data entries
188 entries across 96 versions & 4 rubygems