Sha256: 330f5df63d9b734d37cb57d86d9e2f09568ecba7dd58f913d124a1451cfdca15

Contents?: true

Size: 1.3 KB

Versions: 38

Compression:

Stored size: 1.3 KB

Contents

module DatabaseCleaner
  module Generic
    module Truncation
      def initialize(opts={})
        if !opts.empty? && !(opts.keys - [:only, :except, :pre_count, :reset_ids, :cache_tables]).empty?
          raise ArgumentError, "The only valid options are :only, :except, :pre_count, :reset_ids or :cache_tables. You specified #{opts.keys.join(',')}."
        end
        if opts.has_key?(:only) && opts.has_key?(:except)
          raise ArgumentError, "You may only specify either :only or :except.  Doing both doesn't really make sense does it?"
        end

        @only = opts[:only]
        @tables_to_exclude = Array( (opts[:except] || []).dup ).flatten
        @tables_to_exclude += migration_storage_names
        @pre_count = opts[:pre_count]
        @reset_ids = opts[:reset_ids]
        @cache_tables = opts.has_key?(:cache_tables) ? !!opts[:cache_tables] : true
      end

      def start
        #included for compatability reasons, do nothing if you don't need to
      end

      def clean
        raise NotImplementedError
      end

      private
      def tables_to_truncate
        raise NotImplementedError
      end

      # overwrite in subclasses
      # default implementation given because migration storage need not be present
      def migration_storage_names
        %w[]
      end
    end
  end
end

Version data entries

38 entries across 33 versions & 5 rubygems

Version Path
database_cleaner-1.99.0 lib/database_cleaner/generic/truncation.rb
database_cleaner-1.99.0.beta lib/database_cleaner/generic/truncation.rb
database_cleaner-1.8.5 lib/database_cleaner/generic/truncation.rb
database_cleaner-core-2.0.0.beta lib/database_cleaner/generic/truncation.rb
database_cleaner-1.8.4 lib/database_cleaner/generic/truncation.rb
database_cleaner-1.8.3 lib/database_cleaner/generic/truncation.rb
database_cleaner-1.8.2 lib/database_cleaner/generic/truncation.rb
database_cleaner-1.8.1 lib/database_cleaner/generic/truncation.rb
database_cleaner-1.8.0 lib/database_cleaner/generic/truncation.rb
database_cleaner-1.8.0.beta lib/database_cleaner/generic/truncation.rb
database_cleaner-1.7.0 lib/database_cleaner/generic/truncation.rb
database_cleaner-1.6.2 lib/database_cleaner/generic/truncation.rb
database_cleaner-1.6.1 lib/database_cleaner/generic/truncation.rb
database_cleaner-1.6.0 lib/database_cleaner/generic/truncation.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/generic/truncation.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/generic/truncation.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/generic/truncation.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/generic/truncation.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/generic/truncation.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/generic/truncation.rb