Module: ZerigoDNS::Resource::ClassMethods

Defined in:
lib/zerigodns/resource.rb

Instance Method Summary collapse

Instance Method Details

#process_array(response, body) ⇒ Array

Processes an array response by delegating to the includer’s self.from_response

Parameters:

  • response (Faraday::Response)

    The response

  • body (Array)

    The response body, with root removed

Returns:

  • (Array)

    The resultant array.



24
25
26
27
28
# File 'lib/zerigodns/resource.rb', line 24

def process_array response, body
  body.map do |element|
    from_response response, element
  end
end

#process_response(response) ⇒ Object

Removes the root from the response and hands it off to the class to process it Processes an array response by delegating to the includer’s self.from_response

Parameters:

  • response (Faraday::Response)

    The response

Returns:

  • (Object)

    The result of the parsed response.



10
11
12
13
14
15
16
17
# File 'lib/zerigodns/resource.rb', line 10

def process_response response
  without_root = response.body.values.first
  case
  when without_root.is_a?(Array) then process_array(response, without_root)
  when without_root.is_a?(Hash) then from_response(response, without_root)
  else without_root
  end
end