Sha256: b65ac24a5a9a81653f920d97f0f86d77862f2e5dd671dde98303387a43d9b24a

Contents?: true

Size: 542 Bytes

Versions: 2

Compression:

Stored size: 542 Bytes

Contents

module DatabaseCleaner
  module Mongo
    module Truncation
      
      def clean
        if @only
          collections.each { |c| remove(c) if @only.include?(c.name) }
        else
          collections.each { |c| remove(c) unless @tables_to_exclude.include?(c.name) }
        end
        true
      end

      private
      
      def remove(collection)
        collection.drop_indexes
        collection.remove
      end

      def collections
        database.collections.select { |c| c.name !~ /^system/ }
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
database_cleaner-0.6.1 lib/database_cleaner/mongo/truncation.rb
database_cleaner-0.6.1.rc2 lib/database_cleaner/mongo/truncation.rb