2018-08-03 13:22:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-18 17:45:41 -04:00
|
|
|
module Expirable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
scope :expired, -> { where('expires_at <= ?', Time.current) }
|
|
|
|
end
|
|
|
|
|
2016-10-06 11:19:27 -04:00
|
|
|
def expired?
|
|
|
|
expires? && expires_at <= Time.current
|
|
|
|
end
|
|
|
|
|
2016-08-18 17:45:41 -04:00
|
|
|
def expires?
|
|
|
|
expires_at.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def expires_soon?
|
2016-10-06 11:19:27 -04:00
|
|
|
expires? && expires_at < 7.days.from_now
|
2016-08-18 17:45:41 -04:00
|
|
|
end
|
|
|
|
end
|