Sha256: 86901049fa104335dd08cf5295d13fb9d6fef0e07799ac37a9406b68d89ca2bf

Contents?: true

Size: 840 Bytes

Versions: 188

Compression:

Stored size: 840 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Extensions #:nodoc:
    module Array #:nodoc:

      # This module contains deletion helpers for arrays.
      module Deletion

        # Delete the first object in the array that is equal to the supplied
        # object and return it. This is much faster than performing a standard
        # delete for large arrays ince it attempt to delete multiple in the
        # other.
        #
        # @example Delete the first object.
        #   [ "1", "2", "1" ].delete_one("1")
        #
        # @param [ Object ] object The object to delete.
        #
        # @return [ Object ] The deleted object.
        #
        # @since 2.1.0
        def delete_one(object)
          position = index(object)
          position ? delete_at(position) : nil
        end
      end
    end
  end
end

Version data entries

188 entries across 96 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/array/deletion.rb
mongoid-2.8.1 lib/mongoid/extensions/array/deletion.rb
mongoid-2.8.0 lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/array/deletion.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/array/deletion.rb