Class: Net::DNS::ARecord

Inherits:
Record show all
Defined in:
lib/net/dns/a_record.rb

Constant Summary

Constants included from Validations

Validations::IP_REGEXP, Validations::MAC_REGEXP

Instance Attribute Summary

Attributes inherited from Record

#ip, #resolver, #type

Attributes inherited from Record

#hostname, #logger, #proxy

Instance Method Summary collapse

Methods inherited from Record

#dns_lookup

Methods inherited from Record

#==, #conflicting?, #inspect, #reload!

Methods included from Validations

normalize_ip, normalize_mac, #validate_ip, #validate_mac, #validate_network

Constructor Details

#initialize(opts = { }) ⇒ ARecord


5
6
7
8
# File 'lib/net/dns/a_record.rb', line 5

def initialize opts = { }
  super opts
  @type = "A"
end

Instance Method Details

#attrsObject


40
41
42
# File 'lib/net/dns/a_record.rb', line 40

def attrs
  { :fqdn => hostname, :value => ip, :type => type }
end

#conflictsObject

Returns an array of record objects which are conflicting with our own


27
28
29
# File 'lib/net/dns/a_record.rb', line 27

def conflicts
  @conflicts ||= [dns_lookup(hostname)].delete_if { |c| c == self }.compact
end

#createObject


19
20
21
22
23
24
# File 'lib/net/dns/a_record.rb', line 19

def create
  super
  proxy.set attrs
rescue RestClient::Conflict
  raise generate_conflict_error
end

#destroyObject


14
15
16
17
# File 'lib/net/dns/a_record.rb', line 14

def destroy
  super
  proxy.delete(hostname)
end

#ptrObject


36
37
38
# File 'lib/net/dns/a_record.rb', line 36

def ptr
  dns_lookup(ip)
end

#to_sObject


10
11
12
# File 'lib/net/dns/a_record.rb', line 10

def to_s
  "#{hostname}/#{ip}"
end

#valid?Boolean

Verifies that a record already exists on the dns server


32
33
34
# File 'lib/net/dns/a_record.rb', line 32

def valid?
  self == dns_lookup(hostname)
end