Module: DatabaseRewinder::Compatibility
- Included in:
- DatabaseRewinder
- Defined in:
- lib/database_rewinder/compatibility.rb
Instance Method Summary collapse
-
#[](orm = nil, connection: nil) ⇒ Object
In order to add another database to cleanup, you can give its connection name in one of the forms below:.
- #clean_with(*args, **opts) ⇒ Object
- #cleaning ⇒ Object
- #start ⇒ Object
- #strategy=(args) ⇒ Object
Instance Method Details
#[](orm = nil, connection: nil) ⇒ Object
In order to add another database to cleanup, you can give its connection name in one of the forms below:
# the simplest form
DatabaseRewinder['the_db_name']
or
# with connection: key
DatabaseRewinder[connection: 'the_db_name']
or
# DatabaseCleaner compatible
DatabaseRewinder[:active_record, connection: 'the_db_name']
You can cleanup multiple databases for each test using this configuration.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/database_rewinder/compatibility.rb', line 39 def [](orm = nil, connection: nil, **) if connection.nil? if orm.is_a? String connection = orm elsif orm.is_a?(Hash) && orm.key?(:connection) connection = orm[:connection] end end super connection end |
#clean_with(*args, **opts) ⇒ Object
5 6 7 |
# File 'lib/database_rewinder/compatibility.rb', line 5 def clean_with(*args, **opts) cleaners.each {|c| c.clean_with(*args, **opts)} end |
#cleaning ⇒ Object
9 10 11 12 13 |
# File 'lib/database_rewinder/compatibility.rb', line 9 def cleaning yield ensure clean end |
#start ⇒ Object
15 |
# File 'lib/database_rewinder/compatibility.rb', line 15 def start; end |
#strategy=(args) ⇒ Object
17 18 19 20 21 |
# File 'lib/database_rewinder/compatibility.rb', line 17 def strategy=(args) = args.is_a?(Array) ? args. : {} @only, @except = [:only], [:except] cleaners.each {|c| c.strategy = nil, } end |