Refactor singleton method creation to use Object#define_singleton_method