Sha256: 501b30d5b5bb80f039f0312e58df80f8b2488680a76d1fea0d26845a4d880808

Contents?: true

Size: 827 Bytes

Versions: 11

Compression:

Stored size: 827 Bytes

Contents

require 'database_cleaner/moped/base'
require 'database_cleaner/generic/truncation'

module DatabaseCleaner
  module Moped
    module TruncationBase
      include ::DatabaseCleaner::Moped::Base
      include ::DatabaseCleaner::Generic::Truncation

      def clean
        if @only
          collections.each { |c| session[c].find.remove_all if @only.include?(c) }
        else
          collections.each { |c| session[c].find.remove_all unless @tables_to_exclude.include?(c) }
        end
        true
      end

      private

      def collections
        if db != :default
          session.use(db)
        end

        session['system.namespaces'].find(:name => { '$not' => /system|\$/ }).to_a.map do |collection|
          _, name = collection['name'].split('.', 2)
          name
        end
      end

    end
  end
end

Version data entries

11 entries across 6 versions & 2 rubygems

Version Path
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/database_cleaner-1.2.0/lib/database_cleaner/moped/truncation_base.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/database_cleaner-1.2.0/lib/database_cleaner/moped/truncation_base.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/database_cleaner-1.2.0/lib/database_cleaner/moped/truncation_base.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/database_cleaner-1.2.0/lib/database_cleaner/moped/truncation_base.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/database_cleaner-1.2.0/lib/database_cleaner/moped/truncation_base.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/database_cleaner-1.2.0/lib/database_cleaner/moped/truncation_base.rb
database_cleaner-1.3.0 lib/database_cleaner/moped/truncation_base.rb
database_cleaner-1.2.0 lib/database_cleaner/moped/truncation_base.rb
database_cleaner-1.1.1 lib/database_cleaner/moped/truncation_base.rb
database_cleaner-1.1.0 lib/database_cleaner/moped/truncation_base.rb
database_cleaner-1.0.1 lib/database_cleaner/moped/truncation_base.rb