pocke / rbs_rails

Apache License 2.0
285 stars 34 forks source link

Support Rails7 style enum definitions #268

Open tk0miya opened 1 year ago

tk0miya commented 1 year ago

Since Rails7, the enum definition style has been changed. This uses a private a private method #_enum_methods_module to obtain the registered enum defintions to support both Rails5 and Rails7.

Thanks to @ksss. (refs: https://github.com/pocke/rbs_rails/issues/6)

This is yet another version of https://github.com/pocke/rbs_rails/pull/267 (static analytics approach).

tk0miya commented 9 months ago

Now rebased on #274 .

derikson commented 8 months ago

Unfortunately, this approach doesn't work when instance_methods: false in the enum options. However, I think it's preferable to parsing both the old definition style and the new definition style, and it handles enums defined outside the model file.