Class: SpeedLimiter::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/speed_limiter/config.rb

Overview

config model

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

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_limitObject 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_throttledObject

Returns the value of attribute on_throttled.



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

def on_throttled
  @on_throttled
end

#prefixObject

Returns the value of attribute prefix.



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

def prefix
  @prefix
end

#redisObject

Returns the value of attribute redis.



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

def redis
  @redis
end

#redis_urlObject

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_clientObject



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