Class: Labkit::RateLimit::Rule

Inherits:
Data
  • Object
show all
Defined in:
lib/labkit/rate_limit/rule.rb

Overview

Rule is a value object describing a single rate limit rule.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#actionObject (readonly)

Returns the value of attribute action

Returns:

  • (Object)

    the current value of action



6
7
8
# File 'lib/labkit/rate_limit/rule.rb', line 6

def action
  @action
end

#characteristicsObject (readonly)

Returns the value of attribute characteristics

Returns:

  • (Object)

    the current value of characteristics



6
7
8
# File 'lib/labkit/rate_limit/rule.rb', line 6

def characteristics
  @characteristics
end

#limitObject (readonly)

Returns the value of attribute limit

Returns:

  • (Object)

    the current value of limit



6
7
8
# File 'lib/labkit/rate_limit/rule.rb', line 6

def limit
  @limit
end

#matchObject (readonly)

Returns the value of attribute match

Returns:

  • (Object)

    the current value of match



6
7
8
# File 'lib/labkit/rate_limit/rule.rb', line 6

def match
  @match
end

#periodObject (readonly)

Returns the value of attribute period

Returns:

  • (Object)

    the current value of period



6
7
8
# File 'lib/labkit/rate_limit/rule.rb', line 6

def period
  @period
end