Module: RateLimit::Base

Included in:
RateLimit
Defined in:
lib/rate_limit/base.rb

Instance Method Summary collapse

Instance Method Details

#increment_counters(**args) ⇒ Object



19
20
21
# File 'lib/rate_limit/base.rb', line 19

def increment_counters(**args)
  Worker.new(**args).increment_cache_counter
end

#limit_exceeded?(**args) ⇒ Boolean

Returns:

  • (Boolean)


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

def limit_exceeded?(**args)
  Worker.new(**args).reloaded_limit_exceeded?
end

#reset_counters(**args) ⇒ Object



15
16
17
# File 'lib/rate_limit/base.rb', line 15

def reset_counters(**args)
  Worker.new(**args).clear_cache_counter
end

#throttle(**args) ⇒ Object



5
6
7
8
9
# File 'lib/rate_limit/base.rb', line 5

def throttle(**args)
  worker = Worker.new(**args)
  worker.throttle { yield if block_given? }
  worker.result
end