ruby - How to switch base_uri with httparty -
i trying pass parameter login
method , want switch base uri based on parameter.
like so:
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 # raises net/http response raised raise response.response end end ...
base uri not set when call method, how work?
in httparty, base_uri
class method sets internal options hash. dynamically change within custom class method login
can call method (not assigning if variable).
for example, changing code above, should set base_uri
expect:
... case game_name when "game1" # call method self.base_uri "http://game1" ...
hope helps.
Comments
Post a Comment