Class: Labkit::RateLimit::Rule
- Inherits:
-
Data
- Object
- Data
- Labkit::RateLimit::Rule
- Defined in:
- lib/labkit/rate_limit/rule.rb
Overview
Rule is a value object describing a single rate limit rule.
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#characteristics ⇒ Object
readonly
Returns the value of attribute characteristics.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#period ⇒ Object
readonly
Returns the value of attribute period.
Instance Method Summary collapse
-
#initialize(limit:, period:, characteristics:, match: {}, action: :block) ⇒ Rule
constructor
A new instance of Rule.
Constructor Details
#initialize(limit:, period:, characteristics:, match: {}, action: :block) ⇒ Rule
Returns a new instance of Rule.
7 8 9 10 11 12 13 14 15 |
# File 'lib/labkit/rate_limit/rule.rb', line 7 def initialize(limit:, period:, characteristics:, match: {}, action: :block) super( match: match.transform_keys(&:to_sym).freeze, limit: limit, period: period, action: action.to_sym, characteristics: Array(characteristics).map(&:to_sym).freeze ) end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action
6 7 8 |
# File 'lib/labkit/rate_limit/rule.rb', line 6 def action @action end |
#characteristics ⇒ Object (readonly)
Returns the value of attribute characteristics
6 7 8 |
# File 'lib/labkit/rate_limit/rule.rb', line 6 def characteristics @characteristics end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit
6 7 8 |
# File 'lib/labkit/rate_limit/rule.rb', line 6 def limit @limit end |
#match ⇒ Object (readonly)
Returns the value of attribute match
6 7 8 |
# File 'lib/labkit/rate_limit/rule.rb', line 6 def match @match end |
#period ⇒ Object (readonly)
Returns the value of attribute period
6 7 8 |
# File 'lib/labkit/rate_limit/rule.rb', line 6 def period @period end |