Easy Enumeration Classes

Jeremy Lizt wrote:

I'm wondering what approaches people take to creating enumeration type classes like Gender or State. At Rapleaf we wrote our own gem (with accompanying rails plug-in, so the instances can easily be used as attributes in your ActiveRecords). We packaged this up and discuss it in a post on our blog. I'd love to get people's feedback on whether this is useful to them or if they've got alternative ideas.

http://blog.rapleaf.com/dev/?p=10

http://svn.protocool.com/public/plugins/enumerations_mixin/ has the advantage of caching all the values, but I like your use of boolean methods so you can write

    if object.enum.value?

rather than

   if object.enum === :value

You have also implemented aliases, which would be useful.