我正在尝试将参数传递给login
方法,并且我想根据该参数切换基本 uri。
像这样:
class Managementdb
include HTTParty
def self.login(game_name)
case game_name
when "game1"
self.base_uri = "http://game1"
when "game2"
self.base_uri = "http://game2"
when "game3"
self.base_uri = "http://game3"
end
response = self.get("/login")
if response.success?
@authToken = response["authToken"]
else
# this just raises the net/http response that was raised
raise response.response
end
end
...
当我从一个方法调用它时,基本 uri 没有设置,我该如何让它工作?