[Ovirt-devel] [PATCH] Ruby interface for Cobbler XML-RPC APIs.
John Leach
john at brightbox.co.uk
Fri Aug 1 11:06:55 UTC 2008
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
More information about the ovirt-devel
mailing list