You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After using this gem for the last two years my team and I ended up adding a lot of methods to ask whether an object is a given record, ie:
classCountry < ActiveHash::BaseincludeActiveHash::Enumself.data=[{:id=>1,:name=>"US",:capital=>"Washington, DC"},{:id=>2,:name=>"Canada",:capital=>"Ottawa"},{:id=>3,:name=>"Mexico",:capital=>"Mexico City"}]enum_accessor:name# a method like this for each recorddefus?name == "US"endend
Then, somewhere else:
# Assuming a user has an association to a Country
>> user.country.us?=>true
This could be added programmatically using meta-programming, but I think it'd be a nice feature for the gem to do it either automatically by the enum_accessor or using a different macro for this purpose.
The text was updated successfully, but these errors were encountered:
After using this gem for the last two years my team and I ended up adding a lot of methods to ask whether an object is a given record, ie:
Then, somewhere else:
This could be added programmatically using meta-programming, but I think it'd be a nice feature for the gem to do it either automatically by the
enum_accessor
or using a different macro for this purpose.The text was updated successfully, but these errors were encountered: