summaryrefslogtreecommitdiff
path: root/app/models/concerns/throttled_touch.rb
blob: ad0ff0f20d4bb2c28a83e1fd72bf6893980a35c3 (plain)
1
2
3
4
5
6
7
8
9
10
# ThrottledTouch can be used to throttle the number of updates triggered by
# calling "touch" on an ActiveRecord model.
module ThrottledTouch
  # The amount of time to wait before "touch" can update a record again.
  TOUCH_INTERVAL = 1.minute

  def touch(*args)
    super if (Time.zone.now - updated_at) > TOUCH_INTERVAL
  end
end