class Coppertone::RecordFinder
A helper class for finding SPF records for a domain.
Attributes
dns_client[R]
domain[R]
Public Class Methods
new(dns_client, domain)
click to toggle source
# File lib/coppertone/record_finder.rb, line 6 def initialize(dns_client, domain) @dns_client = dns_client @domain = domain end
Public Instance Methods
record()
click to toggle source
# File lib/coppertone/record_finder.rb, line 11 def record @record ||= begin validate_txt_records spf_dns_record = txt_records.first spf_dns_record ? Record.new(spf_dns_record) : nil end end
txt_records()
click to toggle source
# File lib/coppertone/record_finder.rb, line 20 def txt_records @txt_records ||= begin if Coppertone::Utils::DomainUtils.valid?(domain) dns_client.fetch_txt_records(domain).map { |r| r[:text] } .select { |r| Record.record?(r) } else [] end end end
validate_txt_records()
click to toggle source
# File lib/coppertone/record_finder.rb, line 32 def validate_txt_records raise AmbiguousSpfRecordError if txt_records.size > 1 end