Move db check to the Fizzy module
This commit is contained in:
committed by
Jorge Manrubia
parent
6134407f5e
commit
bab914d4e0
+24
-3
@@ -1,6 +1,27 @@
|
||||
module Fizzy
|
||||
def self.saas?
|
||||
return @saas if defined?(@saas)
|
||||
@saas = !!(ENV["SAAS"] || File.exist?(File.expand_path("../../tmp/saas.txt", __dir__)))
|
||||
class << self
|
||||
def saas?
|
||||
return @saas if defined?(@saas)
|
||||
@saas = !!(ENV["SAAS"] || File.exist?(File.expand_path("../../tmp/saas.txt", __dir__)))
|
||||
end
|
||||
|
||||
def db_adapter
|
||||
@db_adapter ||= DbAdapter.new ENV.fetch("DATABASE_ADAPTER", saas? ? "mysql" : "sqlite")
|
||||
end
|
||||
end
|
||||
|
||||
class DbAdapter
|
||||
def initialize(name)
|
||||
@name = name.to_s
|
||||
end
|
||||
|
||||
def to_s
|
||||
@name
|
||||
end
|
||||
|
||||
# Not using inquiry so that it works before Rails env loads.
|
||||
def sqlite?
|
||||
@name == "sqlite"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user