Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1873 from internetee/1872-zeitwerk-migration
Introduce Zeitwerk class loader
- Loading branch information
Showing
78 changed files
with
626 additions
and
664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Authorization | ||
class RestrictedIP | ||
class RestrictedIp | ||
def initialize(ip) | ||
@ip = ip | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,64 @@ | ||
module Concerns | ||
module Contact | ||
module Archivable | ||
extend ActiveSupport::Concern | ||
module Contact::Archivable | ||
extend ActiveSupport::Concern | ||
|
||
class_methods do | ||
def archivable | ||
unlinked.find_each.select(&:archivable?) | ||
end | ||
end | ||
class_methods do | ||
def archivable | ||
unlinked.find_each.select(&:archivable?) | ||
end | ||
end | ||
|
||
def archivable?(post: false) | ||
inactive = inactive? | ||
def archivable?(post: false) | ||
inactive = inactive? | ||
|
||
log("Found archivable contact id(#{id}), code (#{code})") if inactive && !post | ||
log("Found archivable contact id(#{id}), code (#{code})") if inactive && !post | ||
|
||
inactive | ||
end | ||
inactive | ||
end | ||
|
||
def archive(verified: false, notify: true, extra_log: false) | ||
unless verified | ||
raise 'Contact cannot be archived' unless archivable?(post: true) | ||
end | ||
def archive(verified: false, notify: true, extra_log: false) | ||
unless verified | ||
raise 'Contact cannot be archived' unless archivable?(post: true) | ||
end | ||
|
||
notify_registrar_about_archivation if notify | ||
write_to_registrar_log if extra_log | ||
destroy! | ||
end | ||
notify_registrar_about_archivation if notify | ||
write_to_registrar_log if extra_log | ||
destroy! | ||
end | ||
|
||
private | ||
private | ||
|
||
def notify_registrar_about_archivation | ||
registrar.notifications.create!( | ||
text: I18n.t('contact_has_been_archived', | ||
contact_code: code, orphan_months: Setting.orphans_contacts_in_months) | ||
) | ||
end | ||
def notify_registrar_about_archivation | ||
registrar.notifications.create!( | ||
text: I18n.t('contact_has_been_archived', | ||
contact_code: code, orphan_months: Setting.orphans_contacts_in_months) | ||
) | ||
end | ||
|
||
def inactive? | ||
if DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period) | ||
return true | ||
end | ||
def inactive? | ||
if Version::DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period) | ||
return true | ||
end | ||
|
||
DomainVersion.was_contact_linked?(id) ? false : created_at <= inactivity_period.ago | ||
end | ||
Version::DomainVersion.was_contact_linked?(id) ? false : created_at <= inactivity_period.ago | ||
end | ||
|
||
def inactivity_period | ||
Setting.orphans_contacts_in_months.months | ||
end | ||
def inactivity_period | ||
Setting.orphans_contacts_in_months.months | ||
end | ||
|
||
def log(msg) | ||
@log ||= Logger.new(STDOUT) | ||
@log.info(msg) | ||
end | ||
def log(msg) | ||
@log ||= Logger.new(STDOUT) | ||
@log.info(msg) | ||
end | ||
|
||
def write_to_registrar_log | ||
registrar_name = registrar.accounting_customer_code | ||
archive_path = ENV['contact_archivation_log_file_dir'] | ||
registrar_log_path = "#{archive_path}/#{registrar_name}.txt" | ||
FileUtils.mkdir_p(archive_path) unless Dir.exist?(archive_path) | ||
def write_to_registrar_log | ||
registrar_name = registrar.accounting_customer_code | ||
archive_path = ENV['contact_archivation_log_file_dir'] | ||
registrar_log_path = "#{archive_path}/#{registrar_name}.txt" | ||
FileUtils.mkdir_p(archive_path) unless Dir.exist?(archive_path) | ||
|
||
f = File.new(registrar_log_path, 'a+') | ||
f.write("#{code}\n") | ||
f.close | ||
end | ||
end | ||
f = File.new(registrar_log_path, 'a+') | ||
f.write("#{code}\n") | ||
f.close | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,22 @@ | ||
module Concerns | ||
module Contact | ||
module Disclosable | ||
extend ActiveSupport::Concern | ||
module Contact::Disclosable | ||
extend ActiveSupport::Concern | ||
|
||
class_methods do | ||
attr_accessor :disclosable_attributes | ||
end | ||
class_methods do | ||
attr_accessor :disclosable_attributes | ||
end | ||
|
||
included do | ||
self.disclosable_attributes = %w[name email] | ||
validate :validate_disclosed_attributes | ||
end | ||
included do | ||
self.disclosable_attributes = %w[name email] | ||
validate :validate_disclosed_attributes | ||
end | ||
|
||
private | ||
private | ||
|
||
def validate_disclosed_attributes | ||
return if disclosed_attributes.empty? | ||
def validate_disclosed_attributes | ||
return if disclosed_attributes.empty? | ||
|
||
has_undisclosable_attributes = (disclosed_attributes - self.class.disclosable_attributes) | ||
.any? | ||
errors.add(:disclosed_attributes, :invalid) if has_undisclosable_attributes | ||
end | ||
end | ||
has_undisclosable_attributes = (disclosed_attributes - self.class.disclosable_attributes) | ||
.any? | ||
errors.add(:disclosed_attributes, :invalid) if has_undisclosable_attributes | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Concerns::Domain::Activatable | ||
module Domain::Activatable | ||
extend ActiveSupport::Concern | ||
|
||
def active? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
module Concerns | ||
module Domain | ||
module BulkUpdatable | ||
extend ActiveSupport::Concern | ||
module Domain::BulkUpdatable | ||
extend ActiveSupport::Concern | ||
|
||
def bulk_update_prohibited? | ||
discarded? || statuses_blocks_update? | ||
end | ||
def bulk_update_prohibited? | ||
discarded? || statuses_blocks_update? | ||
end | ||
|
||
def statuses_blocks_update? | ||
prohibited_array = [DomainStatus::SERVER_UPDATE_PROHIBITED, | ||
DomainStatus::CLIENT_UPDATE_PROHIBITED] | ||
prohibited_array.any? { |block_status| statuses.include?(block_status) } | ||
end | ||
end | ||
def statuses_blocks_update? | ||
prohibited_array = [DomainStatus::SERVER_UPDATE_PROHIBITED, | ||
DomainStatus::CLIENT_UPDATE_PROHIBITED] | ||
prohibited_array.any? { |block_status| statuses.include?(block_status) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Concerns::Domain::Deletable | ||
module Domain::Deletable | ||
extend ActiveSupport::Concern | ||
|
||
DELETE_STATUSES = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Concerns::Domain::Discardable | ||
module Domain::Discardable | ||
extend ActiveSupport::Concern | ||
|
||
def keep | ||
|
Oops, something went wrong.