Sha256: e667e647916013ee6744f068badc8abc8063f43dfcf531af8f7f67b9a0d90b6e

Contents?: true

Size: 727 Bytes

Versions: 45

Compression:

Stored size: 727 Bytes

Contents

module RecordStore
  class Record::MX < Record
    attr_accessor :exchange, :preference

    validates :preference, presence: true, numericality:
      {
        only_integer: true,
        greater_than_or_equal_to: 0,
      }
    validates :exchange, presence: true, format:
      {
        with: Record::FQDN_REGEX,
        message: 'is not a fully qualified domain name',
      }

    def initialize(record)
      super
      @exchange = Record.ensure_ends_with_dot(record.fetch(:exchange))
      @preference = Integer(record.fetch(:preference))
    end

    def rdata
      {
        preference: preference,
        exchange: exchange,
      }
    end

    def rdata_txt
      "#{preference} #{exchange}"
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
record_store-5.7.2 lib/record_store/record/mx.rb
record_store-5.7.1 lib/record_store/record/mx.rb
record_store-5.7.0 lib/record_store/record/mx.rb
record_store-5.6.0 lib/record_store/record/mx.rb
record_store-5.5.4 lib/record_store/record/mx.rb