Class: TestData::DetectsDatabaseExistence
- Inherits:
-
Object
- Object
- TestData::DetectsDatabaseExistence
- Defined in:
- lib/test_data/detects_database_existence.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize ⇒ DetectsDatabaseExistence
constructor
A new instance of DetectsDatabaseExistence.
Constructor Details
#initialize ⇒ DetectsDatabaseExistence
Returns a new instance of DetectsDatabaseExistence.
3 4 5 |
# File 'lib/test_data/detects_database_existence.rb', line 3 def initialize @config = TestData.config end |
Instance Method Details
#call ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/test_data/detects_database_existence.rb', line 7 def call rows = ActiveRecord::Base.connection.execute <<~SQL select datname database_name from pg_catalog.pg_database SQL rows.any? { |row| row["database_name"] == @config.database_name } rescue ActiveRecord::NoDatabaseError false end |