Class: Labkit::RateLimit::Result

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

Overview

Result is the return value of Limiter#check. matched? - true if a rule’s match conditions were satisfied exceeded? - true if the matched rule’s counter exceeded its limit action - :block or :log (nil when matched? is false) rule - the matched Rule object (nil when matched? is false) error? - true if Redis was unavailable; result fails open (exceeded? is false)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matched:, exceeded: false, action: nil, rule: nil, error: false) ⇒ Result

Returns a new instance of Result.



12
13
14
# File 'lib/labkit/rate_limit/result.rb', line 12

def initialize(matched:, exceeded: false, action: nil, rule: nil, error: false)
  super
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action

Returns:

  • (Object)

    the current value of action



11
12
13
# File 'lib/labkit/rate_limit/result.rb', line 11

def action
  @action
end

#errorObject (readonly)

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



11
12
13
# File 'lib/labkit/rate_limit/result.rb', line 11

def error
  @error
end

#exceededObject (readonly)

Returns the value of attribute exceeded

Returns:

  • (Object)

    the current value of exceeded



11
12
13
# File 'lib/labkit/rate_limit/result.rb', line 11

def exceeded
  @exceeded
end

#matchedObject (readonly)

Returns the value of attribute matched

Returns:

  • (Object)

    the current value of matched



11
12
13
# File 'lib/labkit/rate_limit/result.rb', line 11

def matched
  @matched
end

#ruleObject (readonly)

Returns the value of attribute rule

Returns:

  • (Object)

    the current value of rule



11
12
13
# File 'lib/labkit/rate_limit/result.rb', line 11

def rule
  @rule
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/labkit/rate_limit/result.rb', line 24

def error?
  error
end

#exceeded?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/labkit/rate_limit/result.rb', line 20

def exceeded?
  exceeded
end

#matched?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/labkit/rate_limit/result.rb', line 16

def matched?
  matched
end