mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 02:05:57 +02:00
parent
39d7c6ad1d
commit
ad0220088a
30 changed files with 697 additions and 59 deletions
31
app/models/concerns/domain/expirable.rb
Normal file
31
app/models/concerns/domain/expirable.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue