Add helper methods for last response

This commit is contained in:
xhh 2015-07-01 18:48:31 +08:00
parent 6f1dd5ce35
commit 846d282ba0
4 changed files with 18 additions and 2 deletions

View File

@ -63,6 +63,14 @@ module {{moduleName}}
response_body = request.response.body
Swagger.configuration.auth_token = response_body['token']
end
def last_response
Thread.current[:swagger_last_response]
end
def last_response=(response)
Thread.current[:swagger_last_response] = response
end
end
end
end

View File

@ -138,7 +138,7 @@ module {{moduleName}}
end
# record as last response
Thread.current[:swagger_last_response] = @response
Swagger.last_response = @response
unless @response.success?
fail ApiError.new(:code => @response.code,

View File

@ -63,6 +63,14 @@ module Petstore
response_body = request.response.body
Swagger.configuration.auth_token = response_body['token']
end
def last_response
Thread.current[:swagger_last_response]
end
def last_response=(response)
Thread.current[:swagger_last_response] = response
end
end
end
end

View File

@ -137,7 +137,7 @@ module Petstore
end
# record as last response
Thread.current[:swagger_last_response] = @response
Swagger.last_response = @response
unless @response.success?
fail ApiError.new(:code => @response.code,