Module: SnappyStats::Config
Instance Attribute Summary collapse
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#raise_connection_errors ⇒ Object
Returns the value of attribute raise_connection_errors.
Instance Method Summary collapse
- #init! ⇒ Object
-
#redis ⇒ Object
Returns the Redis connection.
-
#redis=(arg) ⇒ Object
Set the Redis connection to use.
Instance Attribute Details
#namespace ⇒ Object
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/snappy_stats/config.rb', line 5 def namespace @namespace end |
#raise_connection_errors ⇒ Object
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 |
#redis ⇒ Object
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 |