Exception: Zonesync::ConflictError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/zonesync/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(conflicts) ⇒ ConflictError

Returns a new instance of ConflictError.



27
28
29
# File 'lib/zonesync/errors.rb', line 27

def initialize(conflicts)
  @conflicts = conflicts
end

Instance Method Details

#messageObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/zonesync/errors.rb', line 31

def message
  conflicts_text = @conflicts.sort_by { |_existing, new_rec| new_rec.name }.map do |existing_rec, new_rec|
    "  existing: #{existing_rec}\n  new:      #{new_rec}"
  end.join("\n\n")

  count = @conflicts.length
  record_word = count == 1 ? "record" : "records"
  exists_word = count == 1 ? "exists" : "exist"

  "    The following untracked DNS \#{record_word} already \#{exists_word} and would be overwritten:\n    \#{conflicts_text}\n  MSG\nend\n".chomp