class MockDnsServer::SerialTransaction

Manages RR additions and deletions for a given serial.

Attributes

additions[RW]

serial is the starting serial, i.e. the serial to which the additions and changes will be applied to get to the next serial value.

deletions[RW]

serial is the starting serial, i.e. the serial to which the additions and changes will be applied to get to the next serial value.

serial[RW]

serial is the starting serial, i.e. the serial to which the additions and changes will be applied to get to the next serial value.

zone[RW]

serial is the starting serial, i.e. the serial to which the additions and changes will be applied to get to the next serial value.

Public Class Methods

new(zone, serial, deletions = [], additions = []) click to toggle source

An object containing serial change information

@param zone the zone for which this data applies @param serial a number from 0 to 2^32 - 1, or a SerialNumber instance @param deletions a single RR or an array of RR's representing deletions @param additions a single RR or an array of RR's representing additions

# File lib/mock_dns_server/serial_transaction.rb, line 17
def initialize(zone, serial, deletions = [], additions = [])
  @zone = zone
  @serial = SerialNumber.object(serial)
  @deletions = Array(deletions)
  @additions = Array(additions)
end

Public Instance Methods

ixfr_records(start_serial) click to toggle source

Returns an array of records corresponding to a serial change of 1, including delimiting SOA records, suitable for inclusion in an IXFR response.

# File lib/mock_dns_server/serial_transaction.rb, line 28
def ixfr_records(start_serial)
  records = []
  records << MessageBuilder.soa_answer(name: zone, serial: start_serial)
  deletions.each { |record| records << record }
  records << MessageBuilder.soa_answer(name: zone, serial: serial)
  additions.each { |record| records << record }
  #require 'awesome_print'; puts ''; ap records; puts ''
  records
end
to_s() click to toggle source
# File lib/mock_dns_server/serial_transaction.rb, line 39
def to_s
  s = "Changes to serial #{serial}:\n"
  deletions.each { |d| s << "- #{d}\n" }
  additions.each { |a| s << "+ #{a}\n" }
  s
end