Sha256: 1eb8eeec5a3dc5f5045ccd8d9df47ad0352306391486af4f01c87263bb56975d
Contents?: true
Size: 935 Bytes
Versions: 5
Compression:
Stored size: 935 Bytes
Contents
# encoding: utf-8 module Mongoid #:nodoc: module Persistence #:nodoc: module Atomic #:nodoc: # This class provides the ability to perform an explicit $pullAll # modification on a specific field. class PullAll < Operation # Sends the atomic $pullAll operation to the database. # # @example Persist the new values. # pull_all.persist # # @return [ Object ] The new array value. # # @since 2.0.0 def persist if document[field] values = document.send(field) values.delete_if { |val| value.include?(val) } values.tap do document.collection.update(document._selector, operation("$pullAll"), options) document.changes.delete(field.to_s) if document.persisted? end else return nil end end end end end end
Version data entries
5 entries across 5 versions & 2 rubygems