class RedisClient::Config

Constants

DEFAULT_DB
DEFAULT_HOST
DEFAULT_PORT
DEFAULT_TIMEOUT
DEFAULT_USERNAME

Attributes

host[R]
path[R]
port[R]

Public Class Methods

new( url: nil, host: nil, port: nil, path: nil, username: nil, password: nil, **kwargs ) click to toggle source
Calls superclass method RedisClient::Config::Common::new
# File lib/redis_client/config.rb, line 185
def initialize(
  url: nil,
  host: nil,
  port: nil,
  path: nil,
  username: nil,
  password: nil,
  **kwargs
)
  if url
    url_config = URLConfig.new(url)
    kwargs = {
      ssl: url_config.ssl?,
      db: url_config.db,
    }.compact.merge(kwargs)
    host ||= url_config.host
    port ||= url_config.port
    path ||= url_config.path
    username ||= url_config.username
    password ||= url_config.password
  end

  super(username: username, password: password, **kwargs)

  if @path = path
    @host = nil
    @port = nil
  else
    @host = host || DEFAULT_HOST
    @port = Integer(port || DEFAULT_PORT)
  end
end