thetron / mongoid-enum

Sweet enum sugar for your Mongoid documents
MIT License
117 stars 166 forks source link

value can not include dash #22

Open poc7667 opened 9 years ago

poc7667 commented 9 years ago

I defined enum :lang, [:'zh-TW', :jp]

and I got exception.

.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/mongoid-enum-0.3.0/lib/mongoid/enum.rb:69:in `class_eval': (eval):1: syntax error, unexpected '-', expecting ';' or '\n'
def zh-TW?() self._lang == :zh-TW end
       ^
(eval):1: syntax error, unexpected keyword_self, expecting end-of-input
def zh-TW?() self._lang == :zh-TW end
                 ^ (SyntaxError)
thetron commented 9 years ago

Ah yes. I can see why that might happen.

Given the way the gem (currently) works - the only way around this would be to use underscored values - but I will definitely include a patch for this in the next release.

Thanks for finding this one! :beers: