use define_singleton_method instead of class_eval
Merge pull request #10207 from epiclabs/use_define_singleton_method

use define_singleton_method instead of class_eval