Replace `class_eval` with `define_method` for enum

https://github.com/rails/rails/commit/db41eb8a6ea88b854bf5cd11070ea4245e1639c5#commitcomment-4502683