database_config.rb 1.4 KB
Newer Older
1 2 3 4 5 6 7 8 9
# 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
10
      attr_accessor :owner_name
11 12 13 14 15 16

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

17
      def config
18
        raise NotImplementedError
19 20
      end

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

J
John Crepezzi 已提交
25 26 27 28
      def host
        raise NotImplementedError
      end

29 30 31 32
      def database
        raise NotImplementedError
      end

33
      def adapter
34
        raise NotImplementedError
35 36
      end

37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
      def pool
        raise NotImplementedError
      end

      def checkout_timeout
        raise NotImplementedError
      end

      def reaping_frequency
        raise NotImplementedError
      end

      def idle_timeout
        raise NotImplementedError
      end

53 54 55 56
      def replica?
        raise NotImplementedError
      end

57 58 59 60
      def migrations_paths
        raise NotImplementedError
      end

61 62 63 64 65 66
      def for_current_env?
        env_name == ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
      end
    end
  end
end