Sha256: f21d0408fe7a45a0775f847dba205b07bbae2dfe8ef45a51cfcb446211fa2a94

Contents?: true

Size: 591 Bytes

Versions: 4

Compression:

Stored size: 591 Bytes

Contents

require 'database_cleaner/mongoid/base'
require 'database_cleaner/generic/truncation'

module DatabaseCleaner
  module Mongoid
    class Truncation
      include ::DatabaseCleaner::Mongoid::Base
      include ::DatabaseCleaner::Generic::Truncation

      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 collections
        ::Mongoid.database.collections
      end

  end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
database_cleaner-0.6.0 lib/database_cleaner/mongoid/truncation.rb
database_cleaner-0.6.0.rc.3 lib/database_cleaner/mongoid/truncation.rb
database_cleaner-0.6.0.rc.2 lib/database_cleaner/mongoid/truncation.rb
database_cleaner-0.6.0.rc.1 lib/database_cleaner/mongoid/truncation.rb