mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 03:58:27 +02:00
Refactor
This commit is contained in:
parent
a9e1414ddc
commit
2adbd915f7
1 changed files with 18 additions and 26 deletions
|
@ -64,25 +64,7 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def attach_nameservers(ns_list)
|
def attach_nameservers(ns_list)
|
||||||
ns_list.each do |ns|
|
ns_list.each do |ns|
|
||||||
#ns with detailed attributes
|
attach_nameserver(ns)
|
||||||
if ns.is_a?(Hash)
|
|
||||||
attrs = {hostname: ns[:hostName]}
|
|
||||||
|
|
||||||
if ns[:hostAddr]
|
|
||||||
if ns[:hostAddr].is_a?(Array)
|
|
||||||
ns[:hostAddr].each do |ip|
|
|
||||||
attrs[:ip] = ip unless attrs[:ip]
|
|
||||||
end
|
|
||||||
else
|
|
||||||
attrs[:ip] = ns[:hostAddr]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.nameservers.build(attrs)
|
|
||||||
#ns with just hostname
|
|
||||||
else
|
|
||||||
self.nameservers.build(hostname: ns)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
save
|
save
|
||||||
|
@ -94,13 +76,23 @@ class Domain < ActiveRecord::Base
|
||||||
errors.empty?
|
errors.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
# def validate_nameservers
|
def attach_nameserver(ns)
|
||||||
# nameservers.each do |x|
|
self.nameservers.build(hostname: ns) and return if ns.is_a?(String)
|
||||||
# x.errors.each do |err|
|
|
||||||
# errors.add(:nameservers)
|
attrs = {hostname: ns[:hostName]}
|
||||||
# end
|
|
||||||
# end
|
if ns[:hostAddr]
|
||||||
# end
|
if ns[:hostAddr].is_a?(Array)
|
||||||
|
ns[:hostAddr].each do |ip|
|
||||||
|
attrs[:ip] = ip unless attrs[:ip]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
attrs[:ip] = ns[:hostAddr]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.nameservers.build(attrs)
|
||||||
|
end
|
||||||
|
|
||||||
def add_child_collection_errors(attr_key, epp_obj_name)
|
def add_child_collection_errors(attr_key, epp_obj_name)
|
||||||
send(attr_key).each do |obj|
|
send(attr_key).each do |obj|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue