Class: WhoIsOnline::Configuration
- Inherits:
-
Object
- Object
- WhoIsOnline::Configuration
- Defined in:
- lib/whoisonline/configuration.rb
Constant Summary collapse
- DEFAULT_NAMESPACE =
"whoisonline:user".freeze
Instance Attribute Summary collapse
-
#auto_hook ⇒ Object
Returns the value of attribute auto_hook.
-
#current_user_method ⇒ Object
Returns the value of attribute current_user_method.
-
#heartbeat_interval ⇒ Object
Returns the value of attribute heartbeat_interval.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
- #redis ⇒ Object
-
#throttle ⇒ Object
Returns the value of attribute throttle.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
-
#user_id_method ⇒ Object
Returns the value of attribute user_id_method.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #redis_connection ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/whoisonline/configuration.rb', line 11 def initialize @ttl = 5.minutes @throttle = 60.seconds @user_id_method = :id @current_user_method = :current_user @namespace = DEFAULT_NAMESPACE @auto_hook = true @logger = default_logger @heartbeat_interval = 60.seconds end |
Instance Attribute Details
#auto_hook ⇒ Object
Returns the value of attribute auto_hook.
7 8 9 |
# File 'lib/whoisonline/configuration.rb', line 7 def auto_hook @auto_hook end |
#current_user_method ⇒ Object
Returns the value of attribute current_user_method.
7 8 9 |
# File 'lib/whoisonline/configuration.rb', line 7 def current_user_method @current_user_method end |
#heartbeat_interval ⇒ Object
Returns the value of attribute heartbeat_interval.
7 8 9 |
# File 'lib/whoisonline/configuration.rb', line 7 def heartbeat_interval @heartbeat_interval end |
#logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/whoisonline/configuration.rb', line 7 def logger @logger end |
#namespace ⇒ Object
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/whoisonline/configuration.rb', line 7 def namespace @namespace end |
#redis ⇒ Object
22 23 24 25 26 |
# File 'lib/whoisonline/configuration.rb', line 22 def redis @redis ||= lambda do Redis.new(url: ENV.fetch("REDIS_URL", "redis://127.0.0.1:6379/0")) end end |
#throttle ⇒ Object
Returns the value of attribute throttle.
7 8 9 |
# File 'lib/whoisonline/configuration.rb', line 7 def throttle @throttle end |
#ttl ⇒ Object
Returns the value of attribute ttl.
7 8 9 |
# File 'lib/whoisonline/configuration.rb', line 7 def ttl @ttl end |
#user_id_method ⇒ Object
Returns the value of attribute user_id_method.
7 8 9 |
# File 'lib/whoisonline/configuration.rb', line 7 def user_id_method @user_id_method end |
Instance Method Details
#redis_connection ⇒ Object
28 29 30 31 32 33 |
# File 'lib/whoisonline/configuration.rb', line 28 def redis_connection client = redis.respond_to?(:call) ? redis.call : redis raise ArgumentError, "config.redis must return a Redis-compatible client" unless client.respond_to?(:set) client end |