Class: MockServer::DnsResponse
- Inherits:
-
Object
- Object
- MockServer::DnsResponse
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#additional_records ⇒ Object
Returns the value of attribute additional_records.
-
#answer_records ⇒ Object
Returns the value of attribute answer_records.
-
#authority_records ⇒ Object
Returns the value of attribute authority_records.
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#primary ⇒ Object
Returns the value of attribute primary.
-
#response_code ⇒ Object
Returns the value of attribute response_code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response_code: nil, answer_records: nil, authority_records: nil, additional_records: nil, delay: nil, primary: nil) ⇒ DnsResponse
constructor
A new instance of DnsResponse.
- #to_h ⇒ Object
Constructor Details
#initialize(response_code: nil, answer_records: nil, authority_records: nil, additional_records: nil, delay: nil, primary: nil) ⇒ DnsResponse
Returns a new instance of DnsResponse.
1511 1512 1513 1514 1515 1516 1517 1518 1519 |
# File 'lib/mockserver/models.rb', line 1511 def initialize(response_code: nil, answer_records: nil, authority_records: nil, additional_records: nil, delay: nil, primary: nil) @response_code = response_code @answer_records = answer_records @authority_records = @additional_records = additional_records @delay = delay @primary = primary end |
Instance Attribute Details
#additional_records ⇒ Object
Returns the value of attribute additional_records.
1508 1509 1510 |
# File 'lib/mockserver/models.rb', line 1508 def additional_records @additional_records end |
#answer_records ⇒ Object
Returns the value of attribute answer_records.
1508 1509 1510 |
# File 'lib/mockserver/models.rb', line 1508 def answer_records @answer_records end |
#authority_records ⇒ Object
Returns the value of attribute authority_records.
1508 1509 1510 |
# File 'lib/mockserver/models.rb', line 1508 def @authority_records end |
#delay ⇒ Object
Returns the value of attribute delay.
1508 1509 1510 |
# File 'lib/mockserver/models.rb', line 1508 def delay @delay end |
#primary ⇒ Object
Returns the value of attribute primary.
1508 1509 1510 |
# File 'lib/mockserver/models.rb', line 1508 def primary @primary end |
#response_code ⇒ Object
Returns the value of attribute response_code.
1508 1509 1510 |
# File 'lib/mockserver/models.rb', line 1508 def response_code @response_code end |
Class Method Details
.from_hash(data) ⇒ Object
1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 |
# File 'lib/mockserver/models.rb', line 1532 def self.from_hash(data) return nil if data.nil? answer_data = data['answerRecords'] = data['authorityRecords'] additional_data = data['additionalRecords'] new( response_code: data['responseCode'], answer_records: answer_data&.map { |r| DnsRecord.from_hash(r) }, authority_records: &.map { |r| DnsRecord.from_hash(r) }, additional_records: additional_data&.map { |r| DnsRecord.from_hash(r) }, delay: Delay.from_hash(data['delay']), primary: data['primary'] ) end |
Instance Method Details
#to_h ⇒ Object
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 |
# File 'lib/mockserver/models.rb', line 1521 def to_h result = {} result['responseCode'] = @response_code unless @response_code.nil? result['answerRecords'] = @answer_records.map(&:to_h) if @answer_records result['authorityRecords'] = @authority_records.map(&:to_h) if @authority_records result['additionalRecords'] = @additional_records.map(&:to_h) if @additional_records result['delay'] = @delay.to_h if @delay result['primary'] = @primary unless @primary.nil? result end |