replace define_singleton_method with ruby 1.8 equivalent