Class: Combustion::Database::Reset

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

Constant Summary collapse

RUBY_VERSION_WITH_NEW_SAFE_LOAD_METHOD_SIGNATURE =
"2.6.0"
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.



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

def initialize
  # TODO: remove when no longer support 2.5.8
  if RUBY_VERSION >= RUBY_VERSION_WITH_NEW_SAFE_LOAD_METHOD_SIGNATURE
    ActiveRecord::Base.configurations = YAML.safe_load(
      ERB.new(database_yaml).result, :aliases => true
    )
  else
    ActiveRecord::Base.configurations = YAML.safe_load(
      ERB.new(database_yaml).result, [], [], true
    )
  end
end

Class Method Details

.callObject



20
21
22
# File 'lib/combustion/database/reset.rb', line 20

def self.call
  new.call
end

Instance Method Details

#callObject



37
38
39
40
41
42
43
44
# File 'lib/combustion/database/reset.rb', line 37

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

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