Sha256: d62cbe6234e3d1e262bd81cf7eb3e60f7cc4f135b45427c07fae1c067a4c1cf1

Contents?: true

Size: 878 Bytes

Versions: 5

Compression:

Stored size: 878 Bytes

Contents

module Net
  module DNS
    class ARecord < DNS::Record

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

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

      def destroy
        super
        proxy.delete(hostname)
      end

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

      # Returns an array of record objects which are conflicting with our own
      def conflicts
        @conflicts ||= [dns_lookup(hostname)].delete_if { |c| c == self }.compact
      end

      # Verifies that a record already exists on the dns server
      def valid?
        self == dns_lookup(hostname)
      end

      def ptr
        dns_lookup(ip)
      end

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

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/lib/net/dns/a_record.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/lib/net/dns/a_record.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/lib/net/dns/a_record.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/lib/net/dns/a_record.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/lib/net/dns/a_record.rb