Gavin Kistner
2/10/2005 2:15:00 PM
On Feb 10, 2005, at 6:41 AM, Glenn Parker wrote:
> Robert Klemme wrote:
>> class << self;self;end.class_eval do
>
> This particular trick has shown up a lot on the Ruby list lately.
> It's kind of ugly, but clearly useful. I think it deserves a name, or
> possibly a new keyword. What would you call it, "virtual_class_eval"?
Apparently I haven't been paying attention. What does the above do, and
how does it differ from:
class Foo
def self.add( meth, &block )
self.class_eval{ define_method( meth, &block ) }
end
end
or
class Foo
def add( meth, &block )
self.class.class_eval{ define_method( meth, &block ) }
end
end
?
Is it to add new methods to the instance only, and not all instances
derived from Foo?
--
(-, /\ \/ / /\/