From: Robert Klemme Date: 2008-03-23T20:19:54+09:00 Subject: Re: #meta On 22.03.2008 20:21, Trans wrote: > On Mar 22, 9:39 am, Robert Klemme wrote: >> I am feeling stupid because I seem to overlook something: what is the >> advantage of your approach vs. >> >> class Object >> def meta >> class<> end >> end >> >> ? As far as I can see your functor in this case simply delegates all >> method invocations to the singleton class. Why not directly use / >> return it? > > Try it: > >>> class X >>> meta.attr_accessor >>> end > NoMethodError: private method `attr_accessor' called for # > from (irb):7 So then the only (?) advantage of your proposal is that you can use private methods like ordinary methods. > There's no need for meta at all, you could just use "class << self" > directly, True enough. And "class << self ... end" is not as ugly as "class < But just as some people prefer to use "def self.foo", it's nice to use > module level methods like #class_attr_accessor. That's were #meta > comes in as generalized form rather than defining class level > equivalents for all possible methods. I see. Thanks for the enlightenment. Kind regards robert