Module: SnappyStats::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/snappy_stats/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#namespaceObject

Returns the value of attribute namespace.



5
6
7
# File 'lib/snappy_stats/config.rb', line 5

def namespace
  @namespace
end

#raise_connection_errorsObject

Returns the value of attribute raise_connection_errors.



6
7
8
# File 'lib/snappy_stats/config.rb', line 6

def raise_connection_errors
  @raise_connection_errors
end

Instance Method Details

#init!Object



8
9
10
11
12
13
# File 'lib/snappy_stats/config.rb', line 8

def init!  
  # all keys are prefixed with this namespace
  self.namespace = 'stats'
  # rescue Redis connection errors
  self.raise_connection_errors = false      
end

#redisObject

Returns the Redis connection



29
30
31
# File 'lib/snappy_stats/config.rb', line 29

def redis
  @redis ||= Redis.new
end

#redis=(arg) ⇒ Object

Set the Redis connection to use

arg - A Redis connection or a Hash of Redis connection options

Returns the Redis client



20
21
22
23
24
25
26
# File 'lib/snappy_stats/config.rb', line 20

def redis=(arg)
  if arg.is_a? Redis
    @redis = arg
  else
    @redis = Redis.new(arg)
  end
end