lib/nerve/rate_limiter.rb
# Consume a token, if one is available. Returns true if a token was consumed
# and false otherwise. For a rate-limited action, the action should be
# executed only when `consume` returns true.
Consume a token, if one is available. Returns true if a token was consumed
and false otherwise. For a rate-limited action, the action should be
executed only when `consume` returns true.
Consume a token if one is available . Returns true if a token was consumed and false otherwise . For a rate - limited action the action should be executed only when ` consume ` returns true .
def consume
      return true unless @average_rate.finite?
      new_tokens, now = refill_tokens
      return false unless new_tokens >= 1
      @tokens = new_tokens - 1
      @last_refill = now
      return true
    end
def consume return true unless @average_rate . finite? new_tokens , now = refill_tokens return false unless new_tokens >= 1 @tokens = new_tokens - 1 @last_refill = now return true end
Consume a token, if one is available.
Consume a token if one is available .