Repository navigation
Conversation
|
Interesting. Could you provide a longer explanation please? This changes behavior and API. Needs tests, CHANGELOG, UPGRADING, a fixed build, etc. |
|
Longer explanation is method_missing can hijack constants at a higher level. For example: class MyEnum
include Ruby::Enum
define MY_GOOD_CONST, 'good'
end
MY_HIJACKED_CONST = 'hijacked'.freeze$> MyEnum::MY_GOOD_CONST // good
$> MyEnum::MY_HIJACKED_CONST // hijacked <-- this is badNow it appears that my enum contains the const that is defined outside the Also, using Tests and changelog to follow |
|
How interesting, thanks! |
|
The real risk is having one of your enums get re-defined somewhere else: class MyEnum
include Ruby::Enum
define MY_GOOD_CONST, 'good'
end
MY_GOOD_CONST = 'bad'.freeze$> MyEnum::MY_GOOD_CONST //bad |
|
@dmoss18 Can you see ^^^ please, would like to get this merged. |
|
Bump @dmoss18 |
|
@dmoss18 Will you fix this PR? I'm about to implement this if it's OK from you. |
|
@laertispappas you should finish it, haven't heard from @dmoss18 for a while |
Define constant with const_set instead of "fetching" them with const_missing. These changes were proposed by @dmoss18 in his initial PR (dblock#11). I also add a spec to support the new feature. I kept const_missing method in order to raise the custom Ruby::Enum::Errors::DuplicateKeyError since it provides a handy way to inform the end user for the exception raised.
Define constant with const_set instead of "fetching" them with const_missing. These changes were proposed by @dmoss18 in his initial PR (dblock#11). I also add a spec to support the new feature. I kept const_missing method in order to raise the custom Ruby::Enum::Errors::DuplicateKeyError since it provides a handy way to inform the end user for the exception raised.
|
I'm gonna close this one since it's being addressed in #16 |
Define constant with const_set instead of "fetching" them with const_missing. These changes were proposed by @dmoss18 in his initial PR (dblock#11). I also add a spec to support the new feature. I kept const_missing method in order to raise the custom Ruby::Enum::Errors::DuplicateKeyError since it provides a handy way to inform the end user for the exception raised.
Define constant with const_set instead of "fetching" them with const_missing. These changes were proposed by @dmoss18 in his initial PR (dblock#11). I also add a spec to support the new feature. I kept const_missing method in order to raise the custom Ruby::Enum::Errors::DuplicateKeyError since it provides a handy way to inform the end user for the exception raised.
No description provided.