From: cppcodeguy@... Date: 2010-07-26T15:26:52+09:00 Subject: Re: Beginning meta-programming question ----------MB_8CCFAA2A9BC90F0_33A8_3DCD3_Webmail-m125.sysops.aol.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="us-ascii" I'm a noob myself so sorry if I give incorrect information but I think you= have a going out of scope issue. The inheirtors method is defined within t= he class that starts on line 3. However, the class it's put in is inside th= e extended method on line 2, so what I think is going on is that by the tim= e you're trying to the inheirtors method, its class has already gone out of= scope since it's called after the extended method has ended. =20 -----Original Message----- From: Andrew Wagner To: ruby-talk ML Sent: Sun, Jul 25, 2010 9:48 pm Subject: Beginning meta-programming question I'm pretty new to ruby, and just playing around. I can't work out why the following won't work, though: 1. module TrackInheritors 2. def self.extended(parent) 3. class << parent 4. puts self 5. @@inheritors =3D [] 6. 7. def self.inheritors 8. @@inheritors 9. end 10. 11. def self.inherited(child) 12. @@inheritors << child 13. end 14. end 15. end 16. end 17. 18. class Parent 19. extend TrackInheritors 20. end 21. 22. class Child1 < Parent 23. end 24. 25. class Child2 < Parent 26. end 27. 28. puts Parent.inheritors 29. 30. # -:28: undefined method `inheritors' for Parent:Class (NoMethodError) =20 ----------MB_8CCFAA2A9BC90F0_33A8_3DCD3_Webmail-m125.sysops.aol.com--