obj = SomeObject.new def obj.new_method \"do some things\" end puts obj.new_method > \"do some things\"
This works ok. However, I need to do
It's been a long time since I asked this. In ruby 1.9+, there's a better way of doing this by using define_singleton_method, as follows:
define_singleton_method
obj = SomeObject.new obj.define_singleton_method(:new_method) do "do some things" end