From: Christian Leskowsky Date: 2005-11-13T12:28:04+09:00 Subject: Re: Execute block in context of yielding method's module ------=_Part_3510_18105159.1131852481908 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Interesting... Thanks! On 11/12/05, Ara.T.Howard wrote: > > 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 =3D nil > @host =3D arg if arg > @host > end > def port arg =3D nil > @port =3D 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 > -- > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > | 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 > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > > -- - 'There was an owl lived in an oak. The more he heard, the less he spoke. The less he spoke, the more he heard.' Christian Leskowsky christian.leskowsky@gmail.com ------=_Part_3510_18105159.1131852481908--