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

Symbols for enumeration with spaces #75

Closed
Bialogs opened this issue Feb 12, 2018 · 1 comment
Closed

Symbols for enumeration with spaces #75

Bialogs opened this issue Feb 12, 2018 · 1 comment

Comments

@Bialogs
Copy link
Contributor

Bialogs commented Feb 12, 2018

In enumerations/status.rb

class Status < EnumerateIt::Base
  associate_values(
    :busy,
    :away,
    :'out of office',
    :'in a meeting'
    ...
end

Will error with NameError: wrong constant name OUT OF OFFICE, NameError: wrong constant name IN A MEETING etc.

Workaround involves using a hash instead of an array:

class Status < EnumerateIt::Base
  associate_values(
    busy: 'busy',
    away: 'away',
    out_of_office: 'out of office',
    in_a_meeting: 'in a meeting'
    ...
end

I have a patch I can submit for which should allow the use of symbols with spaces in it if you're interested. The patch involves removing spaces before the call to const_set in base.rb.

I also wanted to provide this solution to others as well.

@lucascaton
Copy link
Owner

Hey @Bialogs - thanks for opening this issue.

I think it makes sense, as symbols with spaces are still valid symbols!
Please submit the patch you mentioned 😄

Thank you!

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

No branches or pull requests

2 participants