class DatabaseCleaner::Cleaners
Public Instance Methods
[](orm, opts = {})
click to toggle source
FIXME this method conflates creation with lookup… both a command and a query. yuck.
# File lib/database_cleaner/configuration.rb, line 12 def [](orm, opts = {}) raise NoORMDetected unless orm fetch([orm, opts]) { add_cleaner(orm, opts) } end
add_cleaner(orm, opts = {})
click to toggle source
TODO privatize the following methods in 2.0
# File lib/database_cleaner/configuration.rb, line 31 def add_cleaner(orm, opts = {}) self[[orm, opts]] = ::DatabaseCleaner::Base.new(orm, opts) end
orm=(orm)
click to toggle source
# File lib/database_cleaner/configuration.rb, line 23 def orm=(orm) add_cleaner(:autodetect) if none? values.each { |cleaner| cleaner.orm = orm } remove_duplicates end
remove_duplicates()
click to toggle source
# File lib/database_cleaner/configuration.rb, line 35 def remove_duplicates replace(reduce(Cleaners.new) do |cleaners, (key, value)| cleaners[key] = value unless cleaners.values.include?(value) cleaners end) end
strategy=(strategy)
click to toggle source
# File lib/database_cleaner/configuration.rb, line 17 def strategy=(strategy) add_cleaner(:autodetect) if none? values.each { |cleaner| cleaner.strategy = strategy } remove_duplicates end