Sha256: de69bfce1af53bcf610035316f89a521b6882259e7f45cf3e3dd7e451ffee47f

Contents?: true

Size: 582 Bytes

Versions: 16

Compression:

Stored size: 582 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 rdata
      { address: address }
    end

    def rdata_txt
      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
        errors.add(:address, 'is invalid')
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
record_store-5.5.3 lib/record_store/record/a.rb
record_store-5.4.3 lib/record_store/record/a.rb
record_store-5.4.2 lib/record_store/record/a.rb
record_store-5.4.1 lib/record_store/record/a.rb
record_store-5.3.0 lib/record_store/record/a.rb
record_store-5.2.2 lib/record_store/record/a.rb
record_store-5.2.1 lib/record_store/record/a.rb
record_store-5.2.0 lib/record_store/record/a.rb
record_store-5.1.1 lib/record_store/record/a.rb
record_store-5.1.0 lib/record_store/record/a.rb
record_store-5.0.5 lib/record_store/record/a.rb
record_store-5.0.4 lib/record_store/record/a.rb
record_store-5.0.3 lib/record_store/record/a.rb
record_store-5.0.2 lib/record_store/record/a.rb
record_store-5.0.1 lib/record_store/record/a.rb
record_store-5.0.0 lib/record_store/record/a.rb