Class: Combustion::Database::Reset

Inherits:
Object
  • Object
show all
Defined in:
lib/combustion/database/reset.rb

Constant Summary collapse

UnsupportedDatabase =
Class.new StandardError
OPERATOR_PATTERNS =
{
  Combustion::Databases::MySQL      => [/mysql/],
  Combustion::Databases::PostgreSQL => [/postgres/, /postgis/],
  Combustion::Databases::SQLite     => [/sqlite/],
  Combustion::Databases::SQLServer  => [/sqlserver/],
  Combustion::Databases::Oracle     => %w[ oci oracle ],
  Combustion::Databases::Firebird   => %w[ firebird ]
}.freeze
RAILS_DEFAULT_ENVIRONMENTS =
%w[ development production test ].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReset

Returns a new instance of Reset.



21
22
23
24
25
# File 'lib/combustion/database/reset.rb', line 21

def initialize
  ActiveRecord::Base.configurations = YAML.safe_load(
    ERB.new(database_yaml).result, [], [], true
  )
end

Class Method Details

.callObject



17
18
19
# File 'lib/combustion/database/reset.rb', line 17

def self.call
  new.call
end

Instance Method Details

#callObject



27
28
29
30
31
32
33
34
# File 'lib/combustion/database/reset.rb', line 27

def call
  resettable_db_configs.each_value do |configuration|
    adapter = configuration["adapter"] ||
              configuration["url"].split("://").first

    operator_class(adapter).new(configuration).reset
  end
end