[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Ovirt-devel] [PATCH] Ruby interface for Cobbler XML-RPC APIs.



On Fri, 2008-08-01 at 02:21 +0000, David Lutterkort wrote:
> Don't you want to cache the connection here, i.e. more something like
> 
>   def self.connection(writable = false)
>      unless @@connection
>        @@connection = XMLRPC::Client.new2("http://#{@@hostname}/cobbler_api#{writable ? '_rw' : ''}")
>      end
>       
>      return @@connection
>   end

Not to turn this into a Ruby style thread but you can do this, which is
shorter, pretty common and actually faster (return is slow):

def self.connection(writable = false)
  @@connections ||= XMLRPC::´╗┐Client.new2("http://#{@@hostname}/cobbler_api#{writable ? '_rw' : ''}")
end

John.
-- 
http://www.brightbox.co.uk - UK Ruby on Rails hosting


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]