dblock / ruby-enum

A handy way to define enums in Ruby.
MIT License
178 stars 23 forks source link

Remove const_missing method in favor of const_set #16

Closed laertispappas closed 7 years ago

laertispappas commented 7 years ago

Define constant with const_set instead of "fetching" them with const_missing. These changes were proposed by @dmoss18 in his initial PR (https://github.com/dblock/ruby-enum/pull/11).

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.

dblock commented 7 years ago

Looks great. Just missing CHANGELOG entry please.

dblock commented 7 years ago

Feel free to make a release with this @laertispappas.

laertispappas commented 7 years ago

Sure. I will. Thanks.

gjtorikian commented 7 years ago

This change has caused some issues in my projects that rely on ruby-enum:

NameError: wrong constant name default
from <path/to/gem>/lib/ruby-enum/enum.rb:34:in `const_set'

The definition of my enum is here.

Am I doing something wrong? I'm not sure why this redefinition error change would now start raising NameError.

dblock commented 7 years ago

@gjtorikian Can you reopen a new issue? Maybe with a failing test, please?

dblock commented 7 years ago

https://github.com/dblock/ruby-enum/issues/17