.... I've been wanting this functionality for years. I even considered
writing an RCR for it. Now I finally figured out a way to do it in
Ruby. And it was surprisingly simple!
module PromoteSelf
def singleton_method_added( meth)
d = %{
def #{meth}(*args)
#{self.name}.#{meth}(self,*args)
end
}
self.class_eval d
end
end
module String::Format
class << self
include PromoteSelf
def jumble( obj, x, y )
p obj+x+y
end
end
end
String::Format.jumble( "TryMe", '!', '!' )
class String
include Format
end
"TryMe".jumble( '!', '!')
Now I _can_ have my cake and eat it too
T.