Sha256: 7e8a3a16a987c5fcfc2dbf4fa626c2fe8a48b7d0283966f30205bd35061606a7

Contents?: true

Size: 617 Bytes

Versions: 16

Compression:

Stored size: 617 Bytes

Contents

module RecordStore
  class Record::A < Record
    attr_accessor :address

    validates_presence_of :address
    validate :valid_address?

    def initialize(record)
      super
      @address = record.fetch(:address)
    end

    def to_s
      "[ARecord] #{fqdn} #{ttl} IN A #{address}"
    end

    def rdata
      { address: address }
    end

    private

    def valid_address?
      begin
        ip = IPAddr.new(address)
        errors.add(:address, 'is not an IPv4 address') unless ip.ipv4?
      rescue IPAddr::InvalidAddressError => e
        errors.add(:address, 'is invalid')
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
record_store-4.0.7 lib/record_store/record/a.rb
record_store-4.0.6 lib/record_store/record/a.rb
record_store-4.0.5 lib/record_store/record/a.rb
record_store-4.0.4 lib/record_store/record/a.rb
record_store-4.0.3 lib/record_store/record/a.rb
record_store-4.0.2 lib/record_store/record/a.rb
record_store-4.0.1 lib/record_store/record/a.rb
record_store-4.0.0 lib/record_store/record/a.rb
record_store-3.1.4 lib/record_store/record/a.rb
record_store-3.1.3 lib/record_store/record/a.rb
record_store-3.1.1 lib/record_store/record/a.rb
record_store-3.1.0 lib/record_store/record/a.rb
record_store-3.0.0 lib/record_store/record/a.rb
record_store-2.1.0 lib/record_store/record/a.rb
record_store-2.0.0 lib/record_store/record/a.rb
record_store-1.0.0 lib/record_store/record/a.rb