Sha256: 653eaab67ebfdad1758ef5ebf449fe6e02ebdfff7ea9a175b187f0dcf0cb0850

Contents?: true

Size: 572 Bytes

Versions: 8

Compression:

Stored size: 572 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Persistence
    module Atomic

      # Performs atomic $unset operations.
      class Unset
        include Operation

        # Sends the atomic $unset operation to the database.
        #
        # @example Persist the new values.
        #   unset.persist
        #
        # @return [ nil ] The new value.
        #
        # @since 2.1.0
        def persist
          prepare do
            fields.each { |f| document.attributes.delete(f) }
            execute("$unset")
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongoid-3.1.7 lib/mongoid/persistence/atomic/unset.rb
mongoid-3.1.6 lib/mongoid/persistence/atomic/unset.rb
mongoid-3.1.5 lib/mongoid/persistence/atomic/unset.rb
mongoid-3.1.4 lib/mongoid/persistence/atomic/unset.rb
mongoid-3.1.3 lib/mongoid/persistence/atomic/unset.rb
mongoid-3.1.2 lib/mongoid/persistence/atomic/unset.rb
mongoid-3.1.1 lib/mongoid/persistence/atomic/unset.rb
mongoid-3.1.0 lib/mongoid/persistence/atomic/unset.rb