mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 03:58:27 +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
|
||||
return unless name
|
||||
body = snapshot
|
||||
delay.update_whois(name, body)
|
||||
delay.update_private_whois(name, body)
|
||||
delay.update_public_whois(name, body)
|
||||
end
|
||||
|
||||
# not sure we need to pass in the params since i don't know if delayed job has access to
|
||||
# all the regular attributes and stuff
|
||||
def update_whois(domain_name, body)
|
||||
wd = WhoisDomain.find_or_initialize_by(name: domain_name)
|
||||
def update_private_whois(domain_name, body)
|
||||
wd = Whois::PublicDomain.find_or_initialize_by(name: domain_name)
|
||||
wd.body = body
|
||||
wd.save!
|
||||
end
|
||||
|
||||
def update_public_whois(domain_name, body)
|
||||
wd = Whois::PrivateDomain.find_or_initialize_by(name: domain_name)
|
||||
wd.body = body
|
||||
wd.save!
|
||||
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
|
||||
database: registry_production
|
||||
|
||||
development_whois:
|
||||
database: whois_development
|
||||
development_private_whois:
|
||||
<<: *default
|
||||
database: whois_private
|
||||
|
||||
test_whois:
|
||||
database: test_whois
|
||||
development_private_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