Method: Async::DNS::Transaction#add

Defined in:
lib/async/dns/transaction.rb

#add(resources, options = {}) ⇒ Object

Append a list of resources.

By default resources are appended to the answers section, but this can be changed by setting options[:section] to either :authority or :additional.

The time-to-live (TTL) of the resources can be specified using options[:ttl] and defaults to DEFAULT_TTL.



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/async/dns/transaction.rb', line 132

def add(resources, options = {})
	# Use the default options if provided:
	options = options.merge(@options)
	
	ttl = options[:ttl] || DEFAULT_TTL
	name = options[:name] || @question.to_s + "."
	
	section = (options[:section] || "answer").to_sym
	method = "add_#{section}".to_sym
	
	resources.each do |resource|
		@server.logger.debug {"#{method}: #{resource.inspect} #{resource.class::TypeValue} #{resource.class::ClassValue}"}
		
		@response.send(method, name, ttl, resource)
	end
end