Class: MockDnsServer::SerialTransaction
- Inherits:
-
Object
- Object
- MockDnsServer::SerialTransaction
- Defined in:
- lib/mock_dns_server/serial_transaction.rb
Overview
Manages RR additions and deletions for a given serial.
Instance Attribute Summary collapse
-
#additions ⇒ Object
serial is the starting serial, i.e.
-
#deletions ⇒ Object
serial is the starting serial, i.e.
-
#serial ⇒ Object
serial is the starting serial, i.e.
-
#zone ⇒ Object
serial is the starting serial, i.e.
Instance Method Summary collapse
-
#initialize(zone, serial, deletions = [], additions = []) ⇒ SerialTransaction
constructor
An object containing serial change information.
-
#ixfr_records(start_serial) ⇒ Object
Returns an array of records corresponding to a serial change of 1, including delimiting SOA records, suitable for inclusion in an IXFR response.
- #to_s ⇒ Object
Constructor Details
#initialize(zone, serial, deletions = [], additions = []) ⇒ SerialTransaction
An object containing serial change information
17 18 19 20 21 22 |
# 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 |
Instance Attribute Details
#additions ⇒ Object
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.
9 10 11 |
# File 'lib/mock_dns_server/serial_transaction.rb', line 9 def additions @additions end |
#deletions ⇒ Object
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.
9 10 11 |
# File 'lib/mock_dns_server/serial_transaction.rb', line 9 def deletions @deletions end |
#serial ⇒ Object
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.
9 10 11 |
# File 'lib/mock_dns_server/serial_transaction.rb', line 9 def serial @serial end |
#zone ⇒ Object
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.
9 10 11 |
# File 'lib/mock_dns_server/serial_transaction.rb', line 9 def zone @zone end |
Instance Method Details
#ixfr_records(start_serial) ⇒ Object
Returns an array of records corresponding to a serial change of 1, including delimiting SOA records, suitable for inclusion in an IXFR response.
28 29 30 31 32 33 34 35 36 |
# 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 ⇒ Object
39 40 41 42 43 44 |
# 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 |