Class: RedisStore::Config

Inherits:
Hash
  • Object
show all
Defined in:
lib/redis_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(address_or_options) ⇒ Config

Returns a new instance of Config.



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

def initialize(address_or_options)
  options = if address_or_options.is_a?(Hash)
    address_or_options
  else
    host, port = address_or_options.split(/\:/)
    port, db = port.split(/\//) if port
    { :host => host, :port => port, :db => db }
  end

  self[:host] = options[:host] if options[:host]
  self[:port] = options[:port] if options[:port]
  self[:db] = options[:db] if options[:db]
end