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

Jason Guiditta jguiditt at redhat.com
Fri Aug 1 15:18:15 UTC 2008


On Fri, 2008-08-01 at 12:06 +0100, John Leach wrote:
> 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.
+1, not to mention that 'return' is just unneeded, since that is what
happens by default, so at the very least it makes the code cleaner




More information about the ovirt-devel mailing list