Module: DatabaseCleaner::ConnectionAdapters::AbstractAdapter
- Defined in:
- lib/database_cleaner/active_record/truncation.rb
Instance Method Summary collapse
- #database_cleaner_table_cache ⇒ Object
-
#database_cleaner_view_cache ⇒ Object
used to be called views but that can clash with gems like schema_plus this gem is not meant to be exposing such an extra interface any way.
- #database_tables ⇒ Object
- #truncate_table(table_name) ⇒ Object
- #truncate_tables(tables) ⇒ Object
Instance Method Details
#database_cleaner_table_cache ⇒ Object
29 30 31 32 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 29 def database_cleaner_table_cache # the adapters don't do caching (#130) but we make the assumption that the list stays the same in tests @database_cleaner_tables ||= database_tables end |
#database_cleaner_view_cache ⇒ Object
used to be called views but that can clash with gems like schema_plus this gem is not meant to be exposing such an extra interface any way
25 26 27 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 25 def database_cleaner_view_cache @views ||= select_values("select table_name from information_schema.views where table_schema = '#{current_database}'") rescue [] end |
#database_tables ⇒ Object
34 35 36 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 34 def database_tables ::ActiveRecord::VERSION::MAJOR >= 5 ? data_sources : tables end |
#truncate_table(table_name) ⇒ Object
38 39 40 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 38 def truncate_table(table_name) raise NotImplementedError end |
#truncate_tables(tables) ⇒ Object
42 43 44 45 46 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 42 def truncate_tables(tables) tables.each do |table_name| self.truncate_table(table_name) end end |