lib/multiverse.rb in multiverse-0.1.0 vs lib/multiverse.rb in multiverse-0.1.1
- old
+ new
@@ -6,11 +6,11 @@
module Multiverse
class << self
attr_writer :db
def db
- @db ||= ENV["DB"]
+ @db ||= ENV["DB"].presence
end
def db_dir
db_dir = db ? "db/#{db}" : "db"
abort "Unknown DB: #{db}" if db && !Dir.exist?(db_dir)
@@ -20,12 +20,16 @@
def parent_class_name
db ? "#{db.camelize}Record" : "ApplicationRecord"
end
def record_class
- record_class = parent_class_name.safe_constantize
- abort "Missing model: #{parent_class_name}" unless record_class
- record_class
+ if db
+ record_class = parent_class_name.safe_constantize
+ abort "Missing model: #{parent_class_name}" unless record_class
+ record_class
+ else
+ ActiveRecord::Base
+ end
end
def migrate_path
"#{db_dir}/migrate"
end