Class: DatabaseCleaner::Cleaners
- Inherits:
-
Hash
- Object
- Hash
- DatabaseCleaner::Cleaners
- Defined in:
- lib/database_cleaner/cleaners.rb
Instance Method Summary collapse
-
#[](orm, **opts) ⇒ Object
FIXME this method conflates creation with lookup…
- #clean ⇒ Object
- #clean_with(*args) ⇒ Object
- #cleaning(&inner_block) ⇒ Object
-
#initialize(hash = {}) ⇒ Cleaners
constructor
A new instance of Cleaners.
- #start ⇒ Object
- #strategy=(strategy) ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Cleaners
Returns a new instance of Cleaners.
5 6 7 |
# File 'lib/database_cleaner/cleaners.rb', line 5 def initialize hash={} super.replace(hash) end |
Instance Method Details
#[](orm, **opts) ⇒ Object
FIXME this method conflates creation with lookup… both a command and a query. yuck.
10 11 12 13 |
# File 'lib/database_cleaner/cleaners.rb', line 10 def [](orm, **opts) raise ArgumentError if orm.nil? fetch([orm, opts]) { add_cleaner(orm, **opts) } end |
#clean ⇒ Object
24 25 26 |
# File 'lib/database_cleaner/cleaners.rb', line 24 def clean values.each { |cleaner| cleaner.clean } end |
#clean_with(*args) ⇒ Object
34 35 36 |
# File 'lib/database_cleaner/cleaners.rb', line 34 def clean_with(*args) values.each { |cleaner| cleaner.clean_with(*args) } end |
#cleaning(&inner_block) ⇒ Object
28 29 30 31 32 |
# File 'lib/database_cleaner/cleaners.rb', line 28 def cleaning(&inner_block) values.inject(inner_block) do |curr_block, cleaner| proc { cleaner.cleaning(&curr_block) } end.call end |
#start ⇒ Object
20 21 22 |
# File 'lib/database_cleaner/cleaners.rb', line 20 def start values.each { |cleaner| cleaner.start } end |
#strategy=(strategy) ⇒ Object
15 16 17 18 |
# File 'lib/database_cleaner/cleaners.rb', line 15 def strategy=(strategy) values.each { |cleaner| cleaner.strategy = strategy } remove_duplicates end |