Class: SpeedLimiter::Config
- Inherits:
-
Object
- Object
- SpeedLimiter::Config
- Defined in:
- lib/speed_limiter/config.rb
Overview
config model
Instance Attribute Summary collapse
-
#no_limit ⇒ Object
(also: #no_limit?)
Returns the value of attribute no_limit.
-
#on_throttled ⇒ Object
Returns the value of attribute on_throttled.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#redis ⇒ Object
Returns the value of attribute redis.
-
#redis_url ⇒ Object
Returns the value of attribute redis_url.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #redis_client ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 |
# File 'lib/speed_limiter/config.rb', line 8 def initialize @redis_url = ENV.fetch("SPEED_LIMITER_REDIS_URL", "redis://localhost:6379/0") @redis = nil @no_limit = false @prefix = "speed_limiter" @on_throttled = nil end |
Instance Attribute Details
#no_limit ⇒ Object Also known as: no_limit?
Returns the value of attribute no_limit.
6 7 8 |
# File 'lib/speed_limiter/config.rb', line 6 def no_limit @no_limit end |
#on_throttled ⇒ Object
Returns the value of attribute on_throttled.
6 7 8 |
# File 'lib/speed_limiter/config.rb', line 6 def on_throttled @on_throttled end |
#prefix ⇒ Object
Returns the value of attribute prefix.
6 7 8 |
# File 'lib/speed_limiter/config.rb', line 6 def prefix @prefix end |
#redis ⇒ Object
Returns the value of attribute redis.
6 7 8 |
# File 'lib/speed_limiter/config.rb', line 6 def redis @redis end |
#redis_url ⇒ Object
Returns the value of attribute redis_url.
6 7 8 |
# File 'lib/speed_limiter/config.rb', line 6 def redis_url @redis_url end |
Instance Method Details
#redis_client ⇒ Object
18 19 20 |
# File 'lib/speed_limiter/config.rb', line 18 def redis_client @redis_client ||= SpeedLimiter::Redis.new(@redis || ::Redis.new(url: redis_url)) end |