Method: RedisClient::URLConfig#db

Defined in:
lib/redis_client/url_config.rb

#dbObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/redis_client/url_config.rb', line 30

def db
  unless @unix
    db_path = uri.path&.delete_prefix("/")
    return Integer(db_path) if db_path && !db_path.empty?
  end

  unless uri.query.nil? || uri.query.empty?
    _, db_query = URI.decode_www_form(uri.query).find do |key, _|
      key == "db"
    end
    return Integer(db_query) if db_query && !db_query.empty?
  end
end