Class: MockDnsServer::HistoryInspections

Inherits:
Object
  • Object
show all
Defined in:
lib/mock_dns_server/history_inspections.rb

Constant Summary collapse

MT =
MessageTransformer

Instance Method Summary collapse

Instance Method Details

#all(*inspections) ⇒ Object



35
36
37
38
39
# File 'lib/mock_dns_server/history_inspections.rb', line 35

def all(*inspections)
  ->(record) do
    inspections.all? { |inspection| inspection.(record) }
  end
end

#any(*inspections) ⇒ Object



41
42
43
44
45
# File 'lib/mock_dns_server/history_inspections.rb', line 41

def any(*inspections)
  ->(record) do
    inspections.any? { |inspection| inspection.(record) }
  end
end

#apply(records, inspection) ⇒ Object



53
54
55
# File 'lib/mock_dns_server/history_inspections.rb', line 53

def apply(records, inspection)
  records.select { |record| inspection.(record) }
end

#none(*inspections) ⇒ Object



47
48
49
50
51
# File 'lib/mock_dns_server/history_inspections.rb', line 47

def none(*inspections)
  ->(record) do
    inspections.none? { |inspection| inspection.(record) }
  end
end

#protocol(protocol) ⇒ Object



31
32
33
# File 'lib/mock_dns_server/history_inspections.rb', line 31

def protocol(protocol)
  ->(record) { record[:protocol] == protocol }
end

#qname(qname) ⇒ Object



20
21
22
23
24
25
# File 'lib/mock_dns_server/history_inspections.rb', line 20

def qname(qname)
  ->(record) do
    qname_in_message = MT.new(record[:message]).qname.to_s
    qname_in_message == qname
  end
end

#qtype(qtype) ⇒ Object



13
14
15
16
17
18
# File 'lib/mock_dns_server/history_inspections.rb', line 13

def qtype(qtype)
  ->(record) do
    qtype_in_message = MT.new(record[:message]).qtype.to_s
    qtype_in_message == qtype
  end
end

#soaObject



27
28
29
# File 'lib/mock_dns_server/history_inspections.rb', line 27

def soa
  qtype('SOA')
end

#type(type) ⇒ Object



9
10
11
# File 'lib/mock_dns_server/history_inspections.rb', line 9

def type(type)
  ->(record) { record[:type] == type }
end