Sha256: 979bd844c8e968ab57f3ea0a95a943e55d747be854f0e987d44fcde3352b0786
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require "multiverse/generators" require "multiverse/patches" require "multiverse/railtie" require "multiverse/version" module Multiverse class << self attr_writer :db def 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) db_dir end def parent_class_name db ? "#{db.camelize}Record" : "ApplicationRecord" end def 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 def env(environment) db ? "#{db}_#{environment}" : environment end end end ActiveSupport.on_load(:active_record) do ActiveRecord::Tasks::DatabaseTasks.singleton_class.prepend Multiverse::DatabaseTasks ActiveRecord::Migration.prepend Multiverse::Migration ActiveRecord::Migrator.prepend Multiverse::Migrator ActiveRecord::SchemaDumper.singleton_class.prepend Multiverse::SchemaDumper end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
multiverse-0.1.2 | lib/multiverse.rb |
multiverse-0.1.1 | lib/multiverse.rb |