BigW Consortium Gitlab

expirable.rb 323 Bytes
Newer Older
1 2 3 4 5 6 7
module Expirable
  extend ActiveSupport::Concern

  included do
    scope :expired, -> { where('expires_at <= ?', Time.current) }
  end

8 9 10 11
  def expired?
    expires? && expires_at <= Time.current
  end

12 13 14 15 16
  def expires?
    expires_at.present?
  end

  def expires_soon?
17
    expires? && expires_at < 7.days.from_now
18 19
  end
end