module DatabaseCleaner
Public Class Methods
[](orm,opts = {})
click to toggle source
# File lib/database_cleaner/configuration.rb, line 15 def [](orm,opts = {}) raise NoORMDetected unless orm init_cleaners # TODO: deprecate # this method conflates creation with lookup. Both a command and a query. Yuck. if @cleaners.has_key? [orm, opts] @cleaners[[orm, opts]] else add_cleaner(orm, opts) end end
add_cleaner(orm,opts = {})
click to toggle source
# File lib/database_cleaner/configuration.rb, line 27 def add_cleaner(orm,opts = {}) init_cleaners cleaner = DatabaseCleaner::Base.new(orm,opts) @cleaners[[orm, opts]] = cleaner @connections << cleaner cleaner end
app_root()
click to toggle source
# File lib/database_cleaner/configuration.rb, line 39 def app_root @app_root ||= Dir.pwd end
app_root=(desired_root)
click to toggle source
# File lib/database_cleaner/configuration.rb, line 35 def app_root=(desired_root) @app_root = desired_root end
can_detect_orm?()
click to toggle source
# File lib/database_cleaner.rb, line 5 def self.can_detect_orm? DatabaseCleaner::Base.autodetect_orm end
clean()
click to toggle source
# File lib/database_cleaner/configuration.rb, line 78 def clean connections.each { |connection| connection.clean } end
Also aliased as: clean!
clean_with(*args)
click to toggle source
# File lib/database_cleaner/configuration.rb, line 90 def clean_with(*args) connections.each { |connection| connection.clean_with(*args) } end
Also aliased as: clean_with!
cleaning(&inner_block)
click to toggle source
# File lib/database_cleaner/configuration.rb, line 84 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 43 def connections # double yuck.. can't wait to deprecate this whole class... unless @cleaners autodetected = ::DatabaseCleaner::Base.new add_cleaner(autodetected.orm) end @connections end
init_cleaners()
click to toggle source
# File lib/database_cleaner/configuration.rb, line 9 def init_cleaners @cleaners ||= {} # ghetto ordered hash.. maintains 1.8 compat and old API @connections ||= [] end
logger()
click to toggle source
# File lib/database_cleaner/configuration.rb, line 56 def logger return @logger if @logger @logger = Logger.new(STDOUT) @logger.level = Logger::ERROR @logger end
logger=(log_source)
click to toggle source
# File lib/database_cleaner/configuration.rb, line 52 def logger=(log_source) @logger = log_source end
orm=(orm)
click to toggle source
# File lib/database_cleaner/configuration.rb, line 69 def orm=(orm) connections.each { |connect| connect.orm = orm } remove_duplicates end
orm_module(symbol)
click to toggle source
# File lib/database_cleaner/configuration.rb, line 104 def orm_module(symbol) case symbol when :active_record DatabaseCleaner::ActiveRecord when :data_mapper DatabaseCleaner::DataMapper when :mongo DatabaseCleaner::Mongo when :mongoid DatabaseCleaner::Mongoid when :mongo_mapper DatabaseCleaner::MongoMapper when :moped DatabaseCleaner::Moped when :couch_potato DatabaseCleaner::CouchPotato when :sequel DatabaseCleaner::Sequel when :ohm DatabaseCleaner::Ohm when :redis DatabaseCleaner::Redis when :neo4j DatabaseCleaner::Neo4j end end
remove_duplicates()
click to toggle source
# File lib/database_cleaner/configuration.rb, line 96 def remove_duplicates temp = [] connections.each do |connect| temp.push connect unless temp.include? connect end @connections = temp end
start()
click to toggle source
# File lib/database_cleaner/configuration.rb, line 74 def start connections.each { |connection| connection.start } end
strategy=(stratagem)
click to toggle source
# File lib/database_cleaner/configuration.rb, line 64 def strategy=(stratagem) connections.each { |connect| connect.strategy = stratagem } remove_duplicates end