You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
823 B
34 lines
823 B
class Domain < ActiveRecord::Base |
|
|
|
before_validation(:on => :update) do |
|
if name_changed? |
|
name_was_pattern = /#{Regexp.escape(name_was)}$/ |
|
each_update_involved_record do |record| |
|
if record.type == 'SOA' |
|
record.reset_serial |
|
record.name = name |
|
else |
|
record.name = record.name.sub(name_was_pattern, name) |
|
end |
|
record.domain = self |
|
end |
|
end |
|
end |
|
|
|
after_update do |
|
if name_changed? |
|
name_was_pattern = /#{Regexp.escape(name_was)}$/ |
|
records.each do |record| |
|
record.name = record.name.sub(name_was_pattern, name) |
|
record.save! |
|
end |
|
end |
|
end |
|
|
|
def each_update_involved_record |
|
yield soa_record |
|
soa_records.each { |record| yield record } |
|
records.each { |record| yield record } |
|
end |
|
|
|
end
|
|
|