class DatabaseCleaner::Configuration

Attributes

cleaners[RW]

Public Class Methods

new() click to toggle source
# File lib/database_cleaner/configuration.rb, line 44
def initialize
  @cleaners ||= Cleaners.new
end

Public Instance Methods

add_cleaner(orm, opts = {}) click to toggle source

TODO privatize the following methods in 2.0

# File lib/database_cleaner/configuration.rb, line 121
def add_cleaner(orm, opts = {})
  if called_externally?(caller)
    DatabaseCleaner.deprecate "Calling `DatabaseCleaner.add_cleaner` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.[]`, instead."
  end
  @cleaners.add_cleaner(orm, opts = {})
end
app_root() click to toggle source
# File lib/database_cleaner/configuration.rb, line 57
def app_root
  DatabaseCleaner.deprecate "Calling `DatabaseCleaner.app_root` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner::ActiveRecord.config_file_location`, instead."
  @app_root ||= Dir.pwd
end
app_root=(value) click to toggle source
# File lib/database_cleaner/configuration.rb, line 62
def app_root= value
  DatabaseCleaner.deprecate "Calling `DatabaseCleaner.app_root=` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner::ActiveRecord.config_file_location=`, instead."
  @app_root = value
end
clean() click to toggle source
# File lib/database_cleaner/configuration.rb, line 81
def clean
  connections.each { |connection| connection.clean }
end
clean!() click to toggle source

TODO remove the following methods in 2.0

# File lib/database_cleaner/configuration.rb, line 97
def clean!
  DatabaseCleaner.deprecate "Calling `DatabaseCleaner.clean!` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.clean`, instead."
  clean
end
clean_with(*args) click to toggle source
# File lib/database_cleaner/configuration.rb, line 91
def clean_with(*args)
  connections.each { |connection| connection.clean_with(*args) }
end
clean_with!(*args) click to toggle source
# File lib/database_cleaner/configuration.rb, line 102
def clean_with!(*args)
  DatabaseCleaner.deprecate "Calling `DatabaseCleaner.clean_with!` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.clean_with`, instead."
  clean_with(*args)
end
cleaning(&inner_block) click to toggle source
# File lib/database_cleaner/configuration.rb, line 85
def cleaning(&inner_block)
  connections.inject(inner_block) do |curr_block, connection|
    proc { connection.cleaning(&curr_block) }
  end.call
end
connections() click to toggle source
# File lib/database_cleaner/configuration.rb, line 111
def connections
  if called_externally?(caller)
    DatabaseCleaner.deprecate "Calling `DatabaseCleaner.connections` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.cleaners`, instead."
  end
  add_cleaner(:autodetect) if @cleaners.none?
  @cleaners.values
end
init_cleaners() click to toggle source
# File lib/database_cleaner/configuration.rb, line 107
def init_cleaners
  DatabaseCleaner.deprecate "Calling `DatabaseCleaner.init_cleaners` is deprecated, and will be removed in database_cleaner 2.0 with no replacement."
end
logger() click to toggle source
# File lib/database_cleaner/configuration.rb, line 67
def logger
  DatabaseCleaner.deprecate "Calling `DatabaseCleaner.logger` is deprecated, and will be removed in database_cleaner 2.0 with no replacement."
  @logger ||= Logger.new(STDOUT).tap { |l| l.level = Logger::ERROR }
end
logger=(value) click to toggle source
# File lib/database_cleaner/configuration.rb, line 72
def logger= value
  DatabaseCleaner.deprecate "Calling `DatabaseCleaner.logger=` is deprecated, and will be removed in database_cleaner 2.0 with no replacement."
  @logger = value
end
remove_duplicates() click to toggle source
# File lib/database_cleaner/configuration.rb, line 128
def remove_duplicates
  if called_externally?(caller)
    DatabaseCleaner.deprecate "Calling `DatabaseCleaner.remove_duplicates` is deprecated, and will be removed in database_cleaner 2.0 with no replacement."
  end
  @cleaners.remove_duplicates
end
start() click to toggle source
# File lib/database_cleaner/configuration.rb, line 77
def start
  connections.each { |connection| connection.start }
end

Private Instance Methods

called_externally?(caller) click to toggle source
# File lib/database_cleaner/configuration.rb, line 137
def called_externally?(caller)
  __FILE__ != caller.first.split(":").first
end