1# frozen_string_literal: true
2
3# ThrottledTouch can be used to throttle the number of updates triggered by
4# calling "touch" on an ActiveRecord model.
5module ThrottledTouch
6  # The amount of time to wait before "touch" can update a record again.
7  TOUCH_INTERVAL = 1.minute
8
9  def touch(*args, **kwargs)
10    super if (Time.zone.now - updated_at) > TOUCH_INTERVAL
11  end
12end
13