Given an object, is there a clean way of creating a new object that 
wraps the original and then adds a new method?

It doesn't have to wrap the old object if there's a way to directly add 
a new method to the object (I'm allowed to change the incoming object).

def extend_it(obj)

  # how do I add a method to obj
  # or create a wrapper for it?

  return obj #or new_obj that quacks like obj, has obj data, and also 
has extra method

end

In my C++ days I would create a class that derives from the original 
class, extends it with a new method, and defines a copy constructor to 
copy the state of the original object.

Thanks
Jeff

-- 
Posted via http://www.ruby-forum.com/.