Refactor domain expiration email

#186
This commit is contained in:
Artur Beljajev 2016-10-28 00:36:12 +03:00
parent 39d7c6ad1d
commit ad0220088a
30 changed files with 697 additions and 59 deletions

View file

@ -0,0 +1,31 @@
module Concerns::Domain::Expirable
extend ActiveSupport::Concern
included do
alias_attribute :expire_time, :valid_to
end
class_methods do
def expired
where("#{attribute_alias(:expire_time)} <= ?", Time.zone.now)
end
end
def registered?
valid_to >= Time.zone.now
end
def expired?
statuses.include?(DomainStatus::EXPIRED)
end
def expirable?
return false if valid_to > Time.zone.now
if expired? && outzone_at.present? && delete_at.present?
return false
end
true
end
end