Module: EPluribusEnum::RepresentsEnumeration::ClassMethods
- Defined in:
- lib/e_pluribus_enum/represents_enumeration.rb
Instance Method Summary collapse
-
#represents_enumeration(field, enum) ⇒ Object
you need the field as an integer in the database, but it doesn’t need to be attr_accessible.
Instance Method Details
#represents_enumeration(field, enum) ⇒ Object
you need the field as an integer in the database, but it doesn’t need to be attr_accessible
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/e_pluribus_enum/represents_enumeration.rb', line 9 def represents_enumeration(field, enum) self.class_eval " def \#{field}\n \#{enum.name}.key_for_value read_attribute(:\#{field})\n end\n def \#{field}=(value)\n write_attribute :\#{field}, \#{enum.name}[value.to_s.to_sym]\n end\n METHOD\nend\n", __FILE__, __LINE__ + 1 |