2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
module Expirable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
scope :expired, -> { where('expires_at <= ?', Time.current) }
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def expired?
|
|
|
|
expires? && expires_at <= Time.current
|
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
def expires?
|
|
|
|
expires_at.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def expires_soon?
|
2017-08-17 22:00:37 +05:30
|
|
|
expires? && expires_at < 7.days.from_now
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|