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

Remove const_missing method in favor of const_set #16

Merged
merged 2 commits into from
Feb 22, 2017

Conversation

laertispappas
Copy link
Collaborator

Define constant with const_set instead of "fetching"
them with const_missing. These changes were proposed
by @dmoss18 in his initial PR (#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.

@@ -169,4 +169,13 @@ class EmptyEnums
expect { EmptyEnums::ORANGE }.to raise_error Ruby::Enum::Errors::UninitializedConstantError
end
end

# https://github.com/dblock/ruby-enum/pull/11
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this comment is useful, it's pretty clear what's going on. CHANGELOG and git blame can always help you find the source.

Copy link
Collaborator Author

@laertispappas laertispappas Feb 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks

@dblock
Copy link
Owner

dblock commented Feb 22, 2017

Looks great. Just missing CHANGELOG entry please.

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.
@dblock dblock merged commit 37cd7f0 into dblock:master Feb 22, 2017
@dblock
Copy link
Owner

dblock commented Feb 22, 2017

Feel free to make a release with this @laertispappas.

@laertispappas
Copy link
Collaborator Author

Sure. I will. Thanks.

kivikakk pushed a commit to gjtorikian/commonmarker that referenced this pull request Feb 23, 2017
This is all we need right now, and dblock/ruby-enum#16 is causing issues
for new installs.
@gjtorikian
Copy link

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
Copy link
Owner

dblock commented Mar 4, 2017

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

@dblock
Copy link
Owner

dblock commented Mar 4, 2017

#17

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

Successfully merging this pull request may close these issues.

3 participants