Module: Enumerize::ActiveRecordSupport::InstanceMethods
- Defined in:
- lib/enumerize/activerecord.rb
Instance Method Summary collapse
-
#becomes(klass) ⇒ Object
Support multiple enumerized attributes.
- #write_attribute(attr_name, value, *options) ⇒ Object
Instance Method Details
#becomes(klass) ⇒ Object
Support multiple enumerized attributes
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/enumerize/activerecord.rb', line 41 def becomes(klass) became = super klass.enumerized_attributes.each do |attr| # Rescue when column associated to the enum does not exist. begin became.send("#{attr.name}=", send(attr.name)) rescue ActiveModel::MissingAttributeError end end became end |
#write_attribute(attr_name, value, *options) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/enumerize/activerecord.rb', line 32 def write_attribute(attr_name, value, *) if self.class.enumerized_attributes[attr_name] _enumerized_values_for_validation[attr_name.to_s] = value end super end |