From: Robert Klemme Date: 2009-05-06T18:34:30+09:00 Subject: Re: modules and classes question 2009/5/5 Marcelo Barbudas : > >> I do not have insights into AWS beyond what can be gatherere from >> http://amazon.rubyforge.org/.  I don't find this pattern very >> appealing.  For something like this to work you need to resort to some >> form of global state (global variable, constant, class instance >> variable, thread local variable) which means there is potential for >> problems when working with multiple threads.  Another issue is that it >> is not obvious, i.e. you do not see that there is something >> transported behind the scenes. >> >> I would at least refrain from placing this pattern in a library unless >> it is thread safe and it is sure that there will and can never be the >> need for more than a single connection which seems doubtful in case of >> AWS. >> > > I understand. How do you mimic an ActiveResource like structure then? > > Something like: > conn = Main.new(user, pass) > conn.resources.method_from_resource_class_that_uses_main_for > the_actual_request_method Yes, or even Main.connect(user, pass) do |conn| conn.resources.method_from_resource_class_that_uses_main_for the_actual_request_method end Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/