I'd support an additional method called `enum_with_prefix` that does as you describe 👍
On Tuesday, December 4, 2018 at 3:03:46 PM UTC-8, Joshua Stowers wrote: > > Sometimes the options of an ActiveRecord enum don't make sense outside the > context of the enum's name. > For example: > > class User < ApplicationRecord > enum authentication_strategy: [:disabled, :password, :captcha] > end > > Calling @user.password? would not make much sense. > > Of course we could prefix this so that it instead reads > @user.authentication_strategy_password?. > This still reads a bit oddly to me. > > Using ActiveSupport's StringInquirer, we could instead do: > @user.authentication_strategy.password?. > To me, this approach makes it most clear that *password? refers > specifically to the concept of authentication_strategy. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.