Remove use of define_singleton_method.
Merge pull request #2166 from take-cheeze/fix_for_1_8

Remove use of define_singleton_method.