Sha256: cf7f53b66ccdd879e040289569f4f13a4916d2b9f15aa5ef332e17d00a85182a

Contents?: true

Size: 681 Bytes

Versions: 188

Compression:

Stored size: 681 Bytes

Contents

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

      # 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
            document.attributes.delete(field)
            collection.update(document.atomic_selector, operation("$unset"), options)
            document.remove_change(value)
          end
        end
      end
    end
  end
end

Version data entries

188 entries across 96 versions & 4 rubygems

Version Path
classiccms-0.5.16 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.15 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.15 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.15 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.14 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.14 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.14 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.13 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.13 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.13 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/atomic/unset.rb
mongoid-2.5.0 lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.12 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.12 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.12 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.11 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.11 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.11 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.10 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.10 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/atomic/unset.rb
classiccms-0.5.10 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/atomic/unset.rb