From: "Ara.T.Howard" Date: 2005-11-13T11:58:40+09:00 Subject: Re: Execute block in context of yielding method's module On Sun, 13 Nov 2005, Christian Leskowsky wrote: > Hey guys, > > I'm very new to ruby. > > This is some freaky shite! Could somebody give me a use case as to when I'd > want to do something like this? > > Thanks! harp:~ > cat a.rb module Connection class << self def host arg = nil @host = arg if arg @host end def port arg = nil @port = arg if arg @port end def configure &block instance_eval &block end end end Connection::configure do host 'http://codeforpeople.com' port 80 end p Connection::host p Connection::port harp:~ > ruby a.rb "http://codeforpeople.com" 80 regards. -a -- =============================================================================== | ara [dot] t [dot] howard [at] gmail [dot] com | all happiness comes from the desire for others to be happy. all misery | comes from the desire for oneself to be happy. | -- bodhicaryavatara ===============================================================================