Newsgroups: comp.lang.ruby
From: Travis D Warlick Jr <warli...@operissystems.com>
Date: Sun, 8 Jul 2007 12:10:00 +0900
Subject: Re: get modules that are in a class?
Aaron Smith wrote: Remember that when you include the module, you're including _all_ the > Wayne E. Seguin wrote: >> On Jul 07, 2007, at 22:00 , Aaron Smith wrote: >>> is it possible to find out what modules have been included inside of a >>> class? >> Yes Aaron it is, via the method "included_modules" >> http://www.ruby-doc.org/core/classes/Module.html#M001697 > What about within a class? > module TestModule > class Test > t = Test.new module's methods (including Module#included_modules) So, use self.class to get the Class object of the current instance (this self.class.included_modules And a debugging efficiency tip: use the Array#sort method with the irb(main):001:0> YourClass.methods.sort -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||