Class: DatabaseCleaner::Configuration
- Inherits:
-
Object
- Object
- DatabaseCleaner::Configuration
- Extended by:
- Forwardable
- Defined in:
- lib/database_cleaner/configuration.rb
Instance Attribute Summary collapse
-
#cleaners ⇒ Object
Returns the value of attribute cleaners.
Instance Method Summary collapse
-
#add_cleaner(orm, opts = {}) ⇒ Object
TODO privatize the following methods in 2.0.
- #app_root ⇒ Object
- #app_root=(value) ⇒ Object
- #clean ⇒ Object
-
#clean! ⇒ Object
TODO remove the following methods in 2.0.
- #clean_with(*args) ⇒ Object
- #clean_with!(*args) ⇒ Object
- #cleaning(&inner_block) ⇒ Object
- #connections ⇒ Object
- #init_cleaners ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #logger ⇒ Object
- #logger=(value) ⇒ Object
- #remove_duplicates ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
44 45 46 |
# File 'lib/database_cleaner/configuration.rb', line 44 def initialize @cleaners ||= Cleaners.new end |
Instance Attribute Details
#cleaners ⇒ Object
Returns the value of attribute cleaners.
55 56 57 |
# File 'lib/database_cleaner/configuration.rb', line 55 def cleaners @cleaners end |
Instance Method Details
#add_cleaner(orm, opts = {}) ⇒ Object
TODO privatize the following methods in 2.0
121 122 123 124 125 126 |
# File 'lib/database_cleaner/configuration.rb', line 121 def add_cleaner(orm, opts = {}) if DatabaseCleaner.called_externally?(__FILE__, caller) DatabaseCleaner.deprecate "Calling `DatabaseCleaner.add_cleaner` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.[]`, instead." end @cleaners.add_cleaner(orm, opts = {}) end |
#app_root ⇒ Object
57 58 59 60 |
# File 'lib/database_cleaner/configuration.rb', line 57 def app_root DatabaseCleaner.deprecate "Calling `DatabaseCleaner.app_root` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner::ActiveRecord.config_file_location`, instead." @app_root ||= Dir.pwd end |
#app_root=(value) ⇒ Object
62 63 64 65 |
# File 'lib/database_cleaner/configuration.rb', line 62 def app_root= value DatabaseCleaner.deprecate "Calling `DatabaseCleaner.app_root=` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner::ActiveRecord.config_file_location=`, instead." @app_root = value end |
#clean ⇒ Object
81 82 83 |
# File 'lib/database_cleaner/configuration.rb', line 81 def clean connections.each { |connection| connection.clean } end |
#clean! ⇒ Object
TODO remove the following methods in 2.0
97 98 99 100 |
# File 'lib/database_cleaner/configuration.rb', line 97 def clean! DatabaseCleaner.deprecate "Calling `DatabaseCleaner.clean!` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.clean`, instead." clean end |
#clean_with(*args) ⇒ Object
91 92 93 |
# File 'lib/database_cleaner/configuration.rb', line 91 def clean_with(*args) connections.each { |connection| connection.clean_with(*args) } end |
#clean_with!(*args) ⇒ Object
102 103 104 105 |
# File 'lib/database_cleaner/configuration.rb', line 102 def clean_with!(*args) DatabaseCleaner.deprecate "Calling `DatabaseCleaner.clean_with!` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.clean_with`, instead." clean_with(*args) end |
#cleaning(&inner_block) ⇒ Object
85 86 87 88 89 |
# File 'lib/database_cleaner/configuration.rb', line 85 def cleaning(&inner_block) connections.inject(inner_block) do |curr_block, connection| proc { connection.cleaning(&curr_block) } end.call end |
#connections ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/database_cleaner/configuration.rb', line 111 def connections if DatabaseCleaner.called_externally?(__FILE__, caller) DatabaseCleaner.deprecate "Calling `DatabaseCleaner.connections` is deprecated, and will be removed in database_cleaner 2.0. Use `DatabaseCleaner.cleaners`, instead." end add_cleaner(:autodetect) if @cleaners.none? @cleaners.values end |
#init_cleaners ⇒ Object
107 108 109 |
# File 'lib/database_cleaner/configuration.rb', line 107 def init_cleaners DatabaseCleaner.deprecate "Calling `DatabaseCleaner.init_cleaners` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." end |
#logger ⇒ Object
67 68 69 70 |
# File 'lib/database_cleaner/configuration.rb', line 67 def logger DatabaseCleaner.deprecate "Calling `DatabaseCleaner.logger` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." @logger ||= Logger.new(STDOUT).tap { |l| l.level = Logger::ERROR } end |
#logger=(value) ⇒ Object
72 73 74 75 |
# File 'lib/database_cleaner/configuration.rb', line 72 def logger= value DatabaseCleaner.deprecate "Calling `DatabaseCleaner.logger=` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." @logger = value end |
#remove_duplicates ⇒ Object
128 129 130 131 132 133 |
# File 'lib/database_cleaner/configuration.rb', line 128 def remove_duplicates if DatabaseCleaner.called_externally?(__FILE__, caller) DatabaseCleaner.deprecate "Calling `DatabaseCleaner.remove_duplicates` is deprecated, and will be removed in database_cleaner 2.0 with no replacement." end @cleaners.remove_duplicates end |
#start ⇒ Object
77 78 79 |
# File 'lib/database_cleaner/configuration.rb', line 77 def start connections.each { |connection| connection.start } end |