Class: DatabaseCleaner::Strategy
- Inherits:
-
Object
- Object
- DatabaseCleaner::Strategy
- Defined in:
- lib/database_cleaner/strategy.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#clean ⇒ Object
Override this method with the actual cleaning procedure.
- #cleaning(&block) ⇒ Object
-
#initialize(options = nil) ⇒ Strategy
constructor
Override this method if the strategy accepts options.
-
#start ⇒ Object
Override this method to start a database transaction if the strategy uses them.
Constructor Details
#initialize(options = nil) ⇒ Strategy
Override this method if the strategy accepts options
6 7 8 9 10 11 |
# File 'lib/database_cleaner/strategy.rb', line 6 def initialize(=nil) if name = self.class.name.sub("DatabaseCleaner::","").sub("::"," ") # e.g. "ActiveRecord Transaction" raise ArgumentError, "No options are available for the #{name} strategy." end end |
Instance Attribute Details
#db ⇒ Object
13 14 15 |
# File 'lib/database_cleaner/strategy.rb', line 13 def db @db ||= :default end |
Instance Method Details
#clean ⇒ Object
Override this method with the actual cleaning procedure. Its the only mandatory method implementation.
23 24 25 |
# File 'lib/database_cleaner/strategy.rb', line 23 def clean raise NotImplementedError end |
#cleaning(&block) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/database_cleaner/strategy.rb', line 27 def cleaning(&block) begin start yield ensure clean end end |
#start ⇒ Object
Override this method to start a database transaction if the strategy uses them
19 20 |
# File 'lib/database_cleaner/strategy.rb', line 19 def start end |