database_config.rb 960 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# frozen_string_literal: true

module ActiveRecord
  class DatabaseConfigurations
    # ActiveRecord::Base.configurations will return either a HashConfig or
    # UrlConfig respectively. It will never return a DatabaseConfig object,
    # as this is the parent class for the types of database configuration objects.
    class DatabaseConfig # :nodoc:
      attr_reader :env_name, :spec_name

      def initialize(env_name, spec_name)
        @env_name = env_name
        @spec_name = spec_name
      end

16
      def config
17
        raise NotImplementedError
18 19
      end

20 21 22 23 24
      def adapter_method
        "#{adapter}_connection"
      end

      def adapter
25
        raise NotImplementedError
26 27
      end

28 29 30 31
      def replica?
        raise NotImplementedError
      end

32 33 34 35
      def migrations_paths
        raise NotImplementedError
      end

36 37 38 39 40 41
      def for_current_env?
        env_name == ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
      end
    end
  end
end