Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support creating T::Enum from Rails enums #3

Open
coreyja opened this issue Dec 17, 2024 · 3 comments
Open

Support creating T::Enum from Rails enums #3

coreyja opened this issue Dec 17, 2024 · 3 comments

Comments

@coreyja
Copy link

coreyja commented Dec 17, 2024

Hello!

Found this gem from the Tapioca Readme, about a place for DSL Compilers that didn't fit in Tapioca directly
I also believe that this gem has some Runtime support as well, which is something I don't believe tapioca supports at all.

I'm coming from using sorbet-rails and one thing that is looking to be painful in migrating is that we are heavily using their Runtime support for creating T::Enum classes from Rails enums (https://github.com/chanzuckerberg/sorbet-rails#typed_enum-instead-of-enum) [We don't use typed_enum but I couldn't find a better place in the Readme to link]

I'm curious if a compiler and support for this is something you might accept in this project?

We will likely write something in-house, but would be more than happy to contribute it back assuming is something others might find valuable!
No problem if not, but wanted to open an issue before we started working on it internally, so we could have a roadmap for the future of the compiler I imagine we will write sometime soon-(ish)!

Edit: Actually not sure if its just runtime code, or if we will need a DSL compiler as well. But I think my original question of it boba might want to support this still stands!

@stathis-alexander
Copy link
Collaborator

Hey @coreyja ,

Very sorry to have missed this!

Found this gem from the Tapioca Readme, about a place for DSL Compilers that didn't fit in Tapioca directly
I also believe that this gem has some Runtime support as well, which is something I don't believe tapioca supports at all.

Yes, correct!

I'm curious if a compiler and support for this is something you might accept in this project?

Yep, this is the very much so in-line with the spirit of the repository. If you submit a compiler for this, we'd happily accept it.

@stathis-alexander
Copy link
Collaborator

HI @coreyja -

I looked into sorbet-rail's support for this. It works through the combination of an AR monkey patch and a compiler, so it's a little nasty. It would be preferable if we could figure out a way to make this modular so that consumers of Boba could opt in (out by default).

I still think there's a place for this here. I would just like to keep things modular if possible.

Side note: We don't use AR enum, we use the enumerize gem and I've written a very simple mixin that makes it easy to use typed enums with enumerize. I can share that if you wish, although I imagine it won't be a straight drop in replacement for AR enums, I'm not sure.

@coreyja
Copy link
Author

coreyja commented Feb 8, 2025

Thanks for looking into the sorbet-rails repo and getting back to me!

Definitely makes sense to want to keep it modular and disabled by default. Will definitely keep that in mind if/when we start coding something up!

Also thanks for mentioning enumerize will take a look at that! And will reach out if I think that mixin would be useful for us too.

No specific plans or timelines for getting an implementation of this put together, but will definitely let you know as we have plans related to it. Whether that means doing something internal at first, or 'straight' to boba, still TBD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants