Skip to content

Remove const_missing method in favor of const_set - #16

Merged
dblock merged 2 commits into
dblock:masterfrom
laertispappas:lp/11/const_set
Feb 22, 2017
Merged

dblock merged 2 commits into
dblock:masterfrom
laertispappas:lp/11/const_set

Conversation

@laertispappas

Copy link
Copy Markdown
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.

Comment thread spec/ruby-enum/enum_spec.rb Outdated
end
end

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

Copy link
Copy Markdown
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.

@laertispappas laertispappas Feb 22, 2017 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍 Thanks

@dblock

dblock commented Feb 22, 2017

Copy link
Copy Markdown
Owner

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

dblock commented Feb 22, 2017

Copy link
Copy Markdown
Owner

Feel free to make a release with this @laertispappas.

@laertispappas

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

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

dblock commented Mar 4, 2017

Copy link
Copy Markdown
Owner

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

@dblock

dblock commented Mar 4, 2017

Copy link
Copy Markdown
Owner

#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