Class: DnsMock::Response::Answer

Inherits:
Object
  • Object
show all
Defined in:
lib/dns_mock/response/answer.rb

Constant Summary collapse

TTL =
1
REVERSE_TYPE_MAPPER =
DnsMock::AVAILABLE_DNS_RECORD_TYPES.each_with_object({}) do |record_type, hash|
  hash[::Resolv::DNS::Resource::IN.const_get(record_type.upcase)] = record_type
end.freeze

Instance Method Summary collapse

Constructor Details

#initialize(records, exception_if_not_found) ⇒ Answer

Returns a new instance of Answer.



11
12
13
14
# File 'lib/dns_mock/response/answer.rb', line 11

def initialize(records, exception_if_not_found)
  @records = records
  @exception_if_not_found = exception_if_not_found
end

Instance Method Details

#build(hostname, record_class) ⇒ Object



16
17
18
19
# File 'lib/dns_mock/response/answer.rb', line 16

def build(hostname, record_class)
  @hostname = hostname
  record_by_type(record_class).map { |record| [hostname, DnsMock::Response::Answer::TTL, record] }
end