Class: RateLimit::Result

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topic:, value:) ⇒ Result

Methods



9
10
11
12
# File 'lib/rate_limit/result.rb', line 9

def initialize(topic:, value:)
  @topic = topic
  @value = value
end

Instance Attribute Details

#intervalObject

Attributes



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

def interval
  @interval
end

#thresholdObject

Attributes



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

def threshold
  @threshold
end

#topicObject

Attributes



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

def topic
  @topic
end

#valueObject

Attributes



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

def value
  @value
end

Instance Method Details

#failure!(worker) ⇒ Object



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

def failure!(worker)
  @success = false
  @threshold  = worker.exceeded_window&.threshold
  @interval   = worker.exceeded_window&.interval
end

#success!Object



18
19
20
# File 'lib/rate_limit/result.rb', line 18

def success!
  @success = true
end

#success?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rate_limit/result.rb', line 14

def success?
  @success
end