Class: Dupe::Network::GetMock
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from Mock
Instance Method Summary collapse
Methods inherited from Mock
#initialize, #match?, #mocked_response
Constructor Details
This class inherits a constructor from Dupe::Network::Mock
Instance Method Details
#process_response(resp, url) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/superdupe/mock.rb', line 44 def process_response(resp, url) case resp when NilClass raise ResourceNotFoundError, "Failed with 404: the request '#{url}' returned nil." when Dupe::Database::Record # if a namespace is available, demodulize the modelname resp = resp.to_xml_safe(:root => resp.demodulize) when Array if resp.empty? resp = [].to_xml :root => 'results' else resp = resp.map {|r| HashPruner.prune(r)}.to_xml(:root => resp.first.demodulize.pluralize) end end Dupe.network.log.add_request :get, url, resp resp end |