Class: SpeedLimiter::ThrottleParams
- Inherits:
-
Object
- Object
- SpeedLimiter::ThrottleParams
- Defined in:
- lib/speed_limiter/throttle_params.rb
Overview
Throttle params model
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#on_throttled ⇒ Object
readonly
Returns the value of attribute on_throttled.
-
#period ⇒ Object
readonly
Returns the value of attribute period.
Instance Method Summary collapse
- #create_state(count: nil, ttl: nil) ⇒ Object
-
#initialize(config:, key:, limit:, period:, on_throttled: nil) ⇒ ThrottleParams
constructor
A new instance of ThrottleParams.
- #redis_key ⇒ Object
Constructor Details
#initialize(config:, key:, limit:, period:, on_throttled: nil) ⇒ ThrottleParams
Returns a new instance of ThrottleParams.
8 9 10 11 12 13 14 |
# File 'lib/speed_limiter/throttle_params.rb', line 8 def initialize(config:, key:, limit:, period:, on_throttled: nil) @config = config @key = key @limit = limit @period = period @on_throttled = on_throttled end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
16 17 18 |
# File 'lib/speed_limiter/throttle_params.rb', line 16 def config @config end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
16 17 18 |
# File 'lib/speed_limiter/throttle_params.rb', line 16 def key @key end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
16 17 18 |
# File 'lib/speed_limiter/throttle_params.rb', line 16 def limit @limit end |
#on_throttled ⇒ Object (readonly)
Returns the value of attribute on_throttled.
16 17 18 |
# File 'lib/speed_limiter/throttle_params.rb', line 16 def on_throttled @on_throttled end |
#period ⇒ Object (readonly)
Returns the value of attribute period.
16 17 18 |
# File 'lib/speed_limiter/throttle_params.rb', line 16 def period @period end |
Instance Method Details
#create_state(count: nil, ttl: nil) ⇒ Object
22 23 24 |
# File 'lib/speed_limiter/throttle_params.rb', line 22 def create_state(count: nil, ttl: nil) State.new(params: self, count: count, ttl: ttl) end |
#redis_key ⇒ Object
18 19 20 |
# File 'lib/speed_limiter/throttle_params.rb', line 18 def redis_key "#{config.prefix}:#{key}" end |