Slide 20
Slide 20 text
module Truncation
OPTS = [:only, :except, :pre_count, :reset_ids, :cache_tables]
def initialize(opts={})
if !opts.empty? && !(opts.keys - OPTS).empty?
msg = <<-EOS
The only valid options are #{OPTS.join(', ')}. You specified #{opts.keys.
join(',')}.
EOS
raise ArgumentError, msg
end
if opts.has_key?(:only) && opts.has_key?(:except)
raise ArgumentError, "You may only specify either :only or :except."
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
DatabaseCleaner::Generic::Truncation