ActiveResource How to set site at runtime?

I have a number of ActiveResource classes that I won’t know the site for
until runtime.

The current definition for one of these resources looks like this

class ResourceSiteDetail < ActiveResource
self.element_name = “site_detail”
self.site = “https://somesubdomain.mydomain.com
self.user = XXXX
self.password = XXXXXX
self.timeout = 10
end

I need to set the site url at runtime rather than at class definition
time
Is it possible to pass the url in as a parameter?

Ideally I would like to do something like

@sd = ResourceSiteDetail.new(“fred”)

and have in the class definition look like this

class ResourceSiteDetail < ActiveResource
self.element_name = “site_detail”
self.site = “https://#{site_name}.mydomain.com” #How do I get
site_name passed in as a parameter?
self.user = XXXX
self.password = XXXXXX
self.timeout = 10
end
But I am totally stumped as to how to achieve this.
Any ideas at all would be greatly appreciated

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs