mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Refactored whois models to a module and subclasses
This commit is contained in:
parent
67519a46f4
commit
00837452a8
11 changed files with 48 additions and 23 deletions
|
@ -11,13 +11,18 @@ module DomainVersionObserver
|
||||||
name = domain_name
|
name = domain_name
|
||||||
return unless name
|
return unless name
|
||||||
body = snapshot
|
body = snapshot
|
||||||
delay.update_whois(name, body)
|
delay.update_private_whois(name, body)
|
||||||
|
delay.update_public_whois(name, body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# not sure we need to pass in the params since i don't know if delayed job has access to
|
def update_private_whois(domain_name, body)
|
||||||
# all the regular attributes and stuff
|
wd = Whois::PublicDomain.find_or_initialize_by(name: domain_name)
|
||||||
def update_whois(domain_name, body)
|
wd.body = body
|
||||||
wd = WhoisDomain.find_or_initialize_by(name: domain_name)
|
wd.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_public_whois(domain_name, body)
|
||||||
|
wd = Whois::PrivateDomain.find_or_initialize_by(name: domain_name)
|
||||||
wd.body = body
|
wd.body = body
|
||||||
wd.save!
|
wd.save!
|
||||||
end
|
end
|
||||||
|
|
2
app/models/whois.rb
Normal file
2
app/models/whois.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
module Whois
|
||||||
|
end
|
5
app/models/whois/private_domain.rb
Normal file
5
app/models/whois/private_domain.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module Whois
|
||||||
|
class PrivateDomain < PrivateServer
|
||||||
|
self.table_name = 'domains'
|
||||||
|
end
|
||||||
|
end
|
6
app/models/whois/private_server.rb
Normal file
6
app/models/whois/private_server.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module Whois
|
||||||
|
class PrivateServer < ActiveRecord::Base
|
||||||
|
self.abstract_class = true
|
||||||
|
establish_connection :"#{Rails.env}_private_whois"
|
||||||
|
end
|
||||||
|
end
|
5
app/models/whois/public_domain.rb
Normal file
5
app/models/whois/public_domain.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module Whois
|
||||||
|
class PublicDomain < PublicServer
|
||||||
|
self.table_name = 'domains'
|
||||||
|
end
|
||||||
|
end
|
6
app/models/whois/public_server.rb
Normal file
6
app/models/whois/public_server.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module Whois
|
||||||
|
class PublicServer < ActiveRecord::Base
|
||||||
|
self.abstract_class = true
|
||||||
|
establish_connection :"#{Rails.env}_public_whois"
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,3 +0,0 @@
|
||||||
class WhoisDomain < WhoisPrivateServer
|
|
||||||
self.table_name = 'domains'
|
|
||||||
end
|
|
|
@ -1,4 +0,0 @@
|
||||||
class WhoisPrivateServer < ActiveRecord::Base
|
|
||||||
self.abstract_class = true
|
|
||||||
establish_connection :"#{Rails.env}_private_whois"
|
|
||||||
end
|
|
|
@ -1,3 +0,0 @@
|
||||||
class WhoisDomain < WhoisPublicServer
|
|
||||||
self.table_name = 'domains'
|
|
||||||
end
|
|
|
@ -1,4 +0,0 @@
|
||||||
class WhoisPublicServer < ActiveRecord::Base
|
|
||||||
self.abstract_class = true
|
|
||||||
establish_connection :"#{Rails.env}_public_whois"
|
|
||||||
end
|
|
|
@ -18,8 +18,18 @@ production:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: registry_production
|
database: registry_production
|
||||||
|
|
||||||
development_whois:
|
development_private_whois:
|
||||||
database: whois_development
|
<<: *default
|
||||||
|
database: whois_private
|
||||||
|
|
||||||
test_whois:
|
development_private_whois:
|
||||||
database: test_whois
|
<<: *default
|
||||||
|
database: whois_public
|
||||||
|
|
||||||
|
production_public_whois:
|
||||||
|
<<: *default
|
||||||
|
database: production_whois_public
|
||||||
|
|
||||||
|
production_private_whois:
|
||||||
|
<<: *default
|
||||||
|
database: production_whois_private
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue