class SidekiqSpy::Config

Attributes

database[RW]
host[RW]
interval[RW]
namespace[RW]
password[RW]
port[RW]
username[RW]

Public Class Methods

new() click to toggle source
# File lib/sidekiq-spy/config.rb, line 15
def initialize
  @username  = nil
  @password  = nil
  @host      = '127.0.0.1'
  @port      = 6379
  @database  = 0
  @namespace = nil
  @interval  = 5
end

Public Instance Methods

url() click to toggle source
# File lib/sidekiq-spy/config.rb, line 35
def url
  url = URI('')
  
  url.scheme   = 'redis'
  url.user     = @username
  url.password = @password
  url.host     = @host
  url.port     = @port
  url.path     = "/#{@database}"
  
  url.to_s
end
url=(url) click to toggle source
# File lib/sidekiq-spy/config.rb, line 25
def url=(url)
  url = URI.parse(url)
  
  @username = url.user if url.user && !url.user.empty?
  @password = url.password if url.password && !url.password.empty?
  @host     = url.host unless url.host.empty?
  @port     = url.port if url.port
  @database = url.path.tr('/', '').to_i unless url.path.empty?
end