# Easy Enumeration Classes

**URL:** <https://www.ruby-forum.com/t/easy-enumeration-classes/118979>\
**Category:** Rails\
**Created:** [November 1, 2007, 10:02pm UTC](https://www.ruby-forum.com/t/easy-enumeration-classes/118979 "2007-11-01T22:02:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eboss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@eboss](https://www.ruby-forum.com/u/eboss)\
**Post date:** [November 1, 2007, 10:02pm UTC](https://www.ruby-forum.com/t/easy-enumeration-classes/118979/1 "2007-11-01T22:02:58Z")

</div>

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://blog.rapleaf.com/dev/?p=10)

---

<div class="post-metadata">

**Author:** ![eboss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@eboss](https://www.ruby-forum.com/u/eboss)\
**Post date:** [November 2, 2007, 1:10pm UTC](https://www.ruby-forum.com/t/easy-enumeration-classes/118979/2 "2007-11-02T13:10:43Z")

</div>

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://blog.rapleaf.com/dev/?p=10)

[http://svn.protocool.com/public/plugins/enumerations\_mixin/](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.

–  
We develop, watch us RoR, in numbers too big to ignore.
