I want to be able to set class attributes (in particular, ActiveResource::Base user, password, site, etc.) and for them to be isolated to a given request, both in terms of thread safety, and so that for the next request they are reset to defaults. For instance, if I set user and password, I want to make sure the user and password set for one user do not accidentally get used for a different user on a subsequent request. I could do this with a before_filter, but that seems like the wrong place to manage a model class' instance variables.
I'm not sure if the threading issue is really a problem, because I understand most rails servers are single threaded, but would it be a good idea to use Thread.current in class_attribute to provide thread safety? Secondly, what do you think of providing a way of resetting the value of class attributes between requests? Perhaps: class_attribute :x, :default => 'x will have this value at the beginning of every request' or class_attribute :x class_initializer :set_x def self.set_x # this gets run at the beginning of every request self.x = 'Initial value' end ActiveResource::Base.user doesn't actually seem to be using class_attribute right now, but I assume it could be updated to do so. Please correct me if I have misunderstood the issues. Thanks, Nick -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
