Sha256: 53b2126ffa8b8894b50da3c6cfed3858853d4ad72f9371d2c5ba911bfaa0678f

Contents?: true

Size: 602 Bytes

Versions: 1

Compression:

Stored size: 602 Bytes

Contents

require "multiverse/generators"
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
      if db
        "#{db.camelize}Record"
      elsif ActiveRecord::VERSION::MAJOR >= 5
        "ApplicationRecord"
      else
        "ActiveRecord::Base"
      end
    end

    def migrate_path
      "#{db_dir}/migrate"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multiverse-0.2.0 lib/multiverse.rb