Sunday, July 31, 2011

enumerated_attribute

Easily code enumerations for your models and expose them as drop-down lists with the enum_select helper, or use any of enumerated_attribute features to simplify coding enumerations in any Ruby object.

Typically, in Ruby, enumerated attributes are implemented with strings, symbols or constants. Often the developer is burdened with repeatedly defining common methods in support of each attribute. enumerated_attribute provides a DRY implementation for enumerations in Rails. Repetitive code such as initializers, accessors, predicate and enumeration methods are automatically generated along with the following features:
  • ActiveRecord integration
  • ActionView form helpers
  • Scaffold generator integration
  • Definable enumeration labels
  • Enum helper methods
  • Dynamic predicate methods
  • Initialization
  • State pattern support (enumerated_state)
https://github.com/jeffp/enumerated_attribute

No comments: