Skip to content

Commit

Permalink
clear unnecessary code in structure, refactored formatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Hasjanov committed Apr 5, 2021
1 parent 28a54d6 commit 9bfdb0f
Show file tree
Hide file tree
Showing 3 changed files with 699 additions and 402 deletions.
24 changes: 14 additions & 10 deletions app/models/concerns/domain/registry_lockable.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Domain::RegistryLockable
extend ActiveSupport::Concern

# status_notes public.hstore,

LOCK_STATUSES = [DomainStatus::SERVER_UPDATE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
Expand All @@ -11,11 +9,7 @@ def apply_registry_lock
return unless registry_lockable?
return if locked_by_registrant?

self.locked_domain_statuses_history = self.statuses.map do |status|
if LOCK_STATUSES.include? status
status
end
end
put_statuses_to_json_history_before_locked

transaction do
self.statuses |= LOCK_STATUSES
Expand Down Expand Up @@ -44,9 +38,7 @@ def remove_registry_lock

transaction do
LOCK_STATUSES.each do |domain_status|
unless self.locked_domain_statuses_history.include? domain_status
statuses.delete(domain_status)
end
delete_domain_statuses_which_not_declared_before domain_status
end
self.locked_by_registrant_at = nil
alert_registrar_lock_changes!(lock: false)
Expand All @@ -64,4 +56,16 @@ def alert_registrar_lock_changes!(lock: true)
attached_obj_type: self.class.name
)
end

private

def put_statuses_to_json_history_before_locked
self.locked_domain_statuses_history = statuses.map do |status|
status if LOCK_STATUSES.include? status
end
end

def delete_domain_statuses_which_not_declared_before(domain_status)
statuses.delete(domain_status) unless locked_domain_statuses_history.include? domain_status
end
end
5 changes: 3 additions & 2 deletions app/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class Domain < ApplicationRecord

attr_accessor :legal_document_id

# serialize :json_statuses_history, HashSerializer
store_accessor :json_statuses_history, :force_delete_domain_statuses_history, :locked_domain_statuses_history
store_accessor :json_statuses_history,
:force_delete_domain_statuses_history,
:locked_domain_statuses_history

alias_attribute :on_hold_time, :outzone_at
alias_attribute :outzone_time, :outzone_at
Expand Down
Loading

0 comments on commit 9bfdb0f

Please sign in to comment.