Module: EventMachine::Udns

Defined in:
lib/em-udns/version.rb,
lib/em-udns/resolver.rb,
ext/em-udns.c,
lib/em-udns/query.rb,
lib/em-udns.rb

Defined Under Namespace

Modules: Watcher Classes: Query, RR_MX, RR_NAPTR, RR_SRV, Resolver, UdnsError

Constant Summary collapse

VERSION =
"0.3.6"

Class Method Summary collapse

Class Method Details

.nameservers=(nameservers) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/em-udns.rb', line 21

def self.nameservers=(nameservers)
  if nameservers
    ENV.delete("NAMESERVERS")
    ENV["NAMESERVERS"] = case nameservers
      # A single nameserver.
      when String
        nameservers
      # Multiple nameservers.
      when Array
        nameservers.join(" ")
      else
        raise Error, "`nameservers' argument must be a String or Array of addresses"
      end
  end
end

.run(resolver) ⇒ Object

Raises:

  • (Error)


37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/em-udns.rb', line 37

def self.run(resolver)
  raise Error, "EventMachine is not running" unless EM.reactor_running?

  raise Error, "`resolver' argument must be a EM::Udns::Resolver instance" unless
    resolver.is_a? EM::Udns::Resolver

  EM.watch resolver.fd, Watcher, resolver do |dns_client|
    dns_client.notify_readable = true
  end

  self
end