mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 19:48:28 +02:00
Fix namespaces for Zeitwerk class loader
This commit is contained in:
parent
32634c7a8b
commit
43b3033991
78 changed files with 666 additions and 704 deletions
31
app/models/contact/transferable.rb
Normal file
31
app/models/contact/transferable.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Contact::Transferable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
validates :auth_info, presence: true
|
||||
after_initialize :generate_auth_info, if: -> { new_record? && auth_info.blank? }
|
||||
end
|
||||
|
||||
def transfer(new_registrar)
|
||||
return identical(new_registrar) if identical(new_registrar)
|
||||
|
||||
new_contact = dup
|
||||
new_contact.registrar = new_registrar
|
||||
new_contact.original = self
|
||||
new_contact.code = nil
|
||||
new_contact.regenerate_code
|
||||
new_contact.regenerate_auth_info
|
||||
new_contact.remove_address unless self.class.address_processing?
|
||||
new_contact.uuid = nil
|
||||
new_contact.save(validate: false)
|
||||
new_contact
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def generate_auth_info
|
||||
self.auth_info = SecureRandom.hex(11)
|
||||
end
|
||||
|
||||
alias_method :regenerate_auth_info, :generate_auth_info
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue