Newsgroups: comp.lang.ruby
From: dbl...@wobblini.net
Date: Sun, 8 Jul 2007 20:32:49 +0900
Local: Sun, Jul 8 2007 7:32 am
Subject: Re: get modules that are in a class?
Hi --
On Sun, 8 Jul 2007, Travis D Warlick Jr wrote: > Aaron Smith wrote: It's not exactly an inclusion thing. Class objects already respond to >> 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 > Remember that when you include the module, you're including _all_ the #included_modules, because Class inherits from Module. > So, use self.class to get the Class object of the current instance (this That will work with any object: > will work from the included modules also), so you should be able to do: > self.class.included_modules "".class.included_modules etc. It's not dependent on your having included a module. David -- 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.
| ||||||||||||||