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.
--
We develop, watch us RoR, in numbers too big to ignore.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---