Sha256: 9a27ba71454c2696ca05d2507e410226027280b1985ecb2542a2a1d7638ef6de

Contents?: true

Size: 622 Bytes

Versions: 6

Compression:

Stored size: 622 Bytes

Contents

require 'database_cleaner/truncation_base'

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

      private

      def connection
        ::MongoMapper.connection
      end

      def collections
        connection.db(database).collections
      end

      def database
        ::MongoMapper.database.name
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
bitfluent-database_cleaner-0.5.2 lib/database_cleaner/mongo_mapper/truncation.rb
database_cleaner-0.5.2 lib/database_cleaner/mongo_mapper/truncation.rb
database_cleaner-0.5.1 lib/database_cleaner/mongo_mapper/truncation.rb
jonrowe-database_cleaner-0.5.2 lib/database_cleaner/mongo_mapper/truncation.rb
saimonmoore-database_cleaner-0.5.0 lib/database_cleaner/mongo_mapper/truncation.rb
database_cleaner-0.5.0 lib/database_cleaner/mongo_mapper/truncation.rb