class DBI::DBRC::YML

A subclass of DBRC designed to handle .dbrc files in YAML format. The public methods of this class are identical to DBRC.

Private Instance Methods

parse_dbrc_config_file(file = @dbrc_file) click to toggle source
# File lib/dbi/dbrc/yaml.rb, line 14
def parse_dbrc_config_file(file = @dbrc_file)
  fh = file.is_a?(StringIO) ? file : File.open(file)
  config = ::YAML.safe_load(fh)

  config.each do |hash|
    hash.each do |db, info|
      next unless db == @database
      next if @user && @user != info['user']
      @user = info['user']
      @password = info['password']
      @driver = info['driver']
      @interval = info['interval']
      @timeout = info['timeout']
      @maximum_reconnects = info['maximum_reconnects']
      break
    end
  end

  raise Error, "No entry found for #{@user}@#{@database}" unless @user && @database
end