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