Replies: 3 comments 12 replies
-
Hey 👋 I hadn't seen that before. I’ll definitely check it out! I’m totally down for working together to promote native-(ish) Ruby enums. I’m especially interested in using them in a Rails context. Did you see the rails plugin? Do you want to grab some time in my calendar? https://savvycal.com/joeldrapper/pair I’ve been meaning to take another look at this gem as I think there are a number of performance optimisations I should do. You should also check out Ecase, which was designed to work with Literal Enums. |
Beta Was this translation helpful? Give feedback.
-
Discussion: Code (Class) Generation vs "On-The-Fly" Dynamic Method Missing "Magic" Looking into your literal_enums machinery / code I see (or my understanding is) that you are using some kind of dynamic method missing "magic" e.g. class << self
def method_missing(name, *args, **kwargs, &block)
return super unless name[0] == name[0].upcase
new(name, *args, **kwargs, &block)
end
# ...
end Anyways, I opted for using "ahead-of-time" code generation, that is, a subclass of a base enum class gets auto-generated via a "macro" to avoid any method_missing "magic". method_missing "magic" is usually considered as an anti-pattern and bad practice (because of unpredictability and performance issues among other cons). Q: Why opt for method_missing "magic"? What convenience syntax / notations does it give you that you cannot get with "classic" code generation? |
Beta Was this translation helpful? Give feedback.
-
Discussion: Q: What ruby enum gems are out there? The line-up so far:
Any others? What's your favorite enum style / gem and why? |
Beta Was this translation helpful? Give feedback.
-
Hello,
sorry if this is the wrong (communication) channel. First let me say that I love your (literal) enums gem.
Some time ago I coded-up my own little enums gem - see https://github.com/rubycocos/core/tree/master/enums.
Anyways, just trying to say hello and maybe if interested a discussion / debate or such on enums in ruby follows.
Did you look at any alternate enum gems in ruby? Might be an idea to bring all or some of the ruby enum gems coders / programmers / designers together for a "consensus" on how to promote the idea to the ruby universe at large or such or see what's different and what's the same (and getting recoded time after time after time after time).
Again sorry if this is the wrong channel. All the best. Cheers. Prost.
Beta Was this translation helpful? Give feedback.
All reactions