Module: RedisClientOptions

Defined in:
lib/redis_client_options.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
# File 'lib/redis_client_options.rb', line 7

def self.included(base)
  base.extend(ClassMethods)
  base.class_eval do
    _configure_options
  end
end

Instance Method Details

#default_redis_optionsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/redis_client_options.rb', line 14

def default_redis_options
  opts = {}
  opts[:password] = config[:password] if config[:password]
  opts[:timeout]  = config[:timeout]  if config[:timeout]
  opts[:db]       = config[:database] if config[:database]
  opts[:scheme]   = config[:transport] if config[:transport]

  if config[:socket]
    opts[:path] = config[:socket]
  else
    opts[:host] = config[:host]
    opts[:port] = config[:port]
  end
  opts
end

#redis_endpointObject



30
31
32
33
34
35
36
# File 'lib/redis_client_options.rb', line 30

def redis_endpoint
  if config[:socket]
    "unix://#{config[:socket]}"
  else
    "#{config[:host]}:#{config[:port]}"
  end
end