define_method and eval in dynamic programming