module Limiter::Mixin
Public Instance Methods
limit_method(method, rate:, interval: 60, &b)
click to toggle source
Calls superclass method
# File lib/limiter/mixin.rb, line 5 def limit_method(method, rate:, interval: 60, &b) queue = RateQueue.new(rate, interval: interval, &b) mixin = Module.new do define_method(method) do |*args, **options, &blk| queue.shift options.empty? ? super(*args, &blk) : super(*args, **options, &blk) end end prepend mixin end