tests/cimi/test_helper.rb
# Find the model class that can process the body of the HTTP response
# +resp+
Find the model class that can process the body of the HTTP response
Find the model class that can process the body of the HTTP response
def model_class(resp)
      resource = nil
      ct = resp.content_type
      if ct == "application/json"
        resp.json["resourceURI"].wont_be_nil
        resource = resp.json["resourceURI"].split("/").last
      elsif ct == "application/xml"
        if resp.xml.root.name == "Collection"
          resource = resp.xml.root["resourceURI"].split("/").last
        else
          resource = resp.xml.root.name
        end
      elsif resp.body.nil? || resp.body.size == 0
        raise "Can not construct model from empty body"
      else
        raise "Unexpected content type #{resp.content_type}"
      end
      CIMI::Model::const_get(resource)
    end
def model_class ( resp ) resource = nil ct = resp . content_type if ct == "application/json" resp . json [ "resourceURI" ] . wont_be_nil resource = resp . json [ "resourceURI" ] . split ( "/" ) . last elsif ct == "application/xml" if resp . xml . root . name == "Collection" resource = resp . xml . root [ "resourceURI" ] . split ( "/" ) . last else resource = resp . xml . root . name end elsif resp . body . nil? || resp . body . size == 0 raise "Can not construct model from empty body" else raise "Unexpected content type #{resp.content_type}" end CIMI :: Model :: const_get ( resource ) end
Find the model class that can process the body of the HTTP response
+resp+
Find the model class that can process the body of the HTTP response + resp +
resp
<not_specific>