Hi,

I want to copy code from one class to another at runtime.

------------------
class A
  def a 
  end
end

class B < Other
end

copy(A, B) #do magic 

B.new.a
-------------------

The easiest way would be inheritance of course, but
the receiving class has its own inheritance structure
and there is no is_a relation between these classes.

The most elegant way would be the use of the standard
include-mechanism of ruby, but this works only for modules.
(Is there a way to turn a class into a module?)

The third way I encountered, is the use of UnboundMethod's.
I thought it might be possible to copy all methods from
one class to another class, but this does not work as expected.

Is there a possibilty to reeavaluate the code of A in the 
context of B?

Anybody has an idea, how to achieve this cut&paste problem? 

Best regards,
Matthias
__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.comm