From: kent yip Date: 2010-07-24T13:28:48+09:00 Subject: Unsubscribe --_fe0b51a0-9939-4fdb-b278-c7dd62127ed2_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable > Date: Sat=2C 24 Jul 2010 06:30:10 +0900 > From: alan@blogometer.com > Subject: Re: Determining the Source File of a Class > To: ruby-talk@ruby-lang.org >=20 > Ryan Davis wrote: > > On Jul 23=2C 2010=2C at 13:40 =2C Alan Gutierrez wrote: > >=20 > >> I'm trying to debug a bug where I seem to have a class that has two de= fintions=2C the one I know of=2C and another one=2C somewhere=2C the one I'= m getting when I attempt to use the class. > >> > >> Given a class=2C is there a way to get name of the file in which it wa= s defined? > >> > >> MyClass.defintion_file > >> > >> Something like that? > >=20 > > Classes in ruby are "open"=2C which means that they can be extended at = any time. So there isn't really a "definition" (at least=2C for a single lo= cation) of a given class. >=20 > Thank you. That answers my question. >=20 > > You also have the case where something isn't opened to have stuff added= to it=2C but instead it can be extended by modules instead. > >=20 > > If you want=2C you can play with the reflective hooks in Module: method= _added=2C included=2C extended=2C etc. >=20 > Sounds like fire hose=2C but I'm sure there's a clever Ruby way to contro= l=20 > the torrent. >=20 > Fortunately=2C I seem to have found the other definition that is being=20 > invoked using `find` and `grep`. >=20 > --=20 > Alan Gutierrez - alan@blogometer.com - http://twitter.com/bigeasy >=20 =20 _________________________________________________________________ MSN Dating: Find someone special. Start now. http://go.microsoft.com/?linkid=3D9734384= --_fe0b51a0-9939-4fdb-b278-c7dd62127ed2_--