lib/traffic_jam/limit_group.rb
# Attempt to increment the limits by the given amount. Does not increment
# if incrementing would exceed any limit.
#
# @param amount [Integer] amount to increment by
# @param time [Time] optional time of increment
# @return [Boolean] whether increment operation was successful
Attempt to increment the limits by the given amount. Does not increment
if incrementing would exceed any limit.
Attempt to increment the limits by the given amount . Does not increment if incrementing would exceed any limit .
def increment(amount = 1, time: Time.now)
      exceeded_index = limits.find_index do |limit|
        !limit.increment(amount, time: time)
      end
      if exceeded_index
        limits[0...exceeded_index].each do |limit|
          limit.decrement(amount, time: time)
        end
      end
      exceeded_index.nil?
    end
def increment ( amount = 1 , time : Time . now ) exceeded_index = limits . find_index do | limit | ! limit . increment ( amount , time : time ) end if exceeded_index limits [ 0 ... exceeded_index ] . each do | limit | limit . decrement ( amount , time : time ) end end exceeded_index . nil? end
Attempt to increment the limits by the given amount.
Attempt to increment the limits by the given amount .
whether increment operation was successful
whether increment operation was successful
Boolean
amount
amount to increment by
amount to increment by
time
optional time of increment
optional time of increment
now
<not_specific>