Access Enum as Constant
sshaw opened this issue · 1 comments
sshaw commented
First off thanks for the great lib:exclamation:
Second, call me nostalgic, but being able to access the enums as a constant would be a nice addition. For example:
class State < ActiveEnum::Base
value 1 => "Available"
value 2 => "In Progress"
# ...
end
State::AVAILABLE
State::IN_PROGRESS
It's sorta almost there now with:
State["IN_PROGRESS"]
Let me know what you think. If so I'll submit a pull request.
adzap commented
Totally understand your nostalgia. This gem is a dirty hybrid of the idea of an enum. Solving common needs but not being purist. The contract of having values as constants is something that can't be fulfilled in many apps because the name is not able to be defined as a constant (eg. punctuation or similar).
It could however be added as an extension to the gem and activated in the config. I would leave that for you to investigate.