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
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/enumerize/activerecord.rb', line 35 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
26 27 28 29 30 31 32 |
# File 'lib/enumerize/activerecord.rb', line 26 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 |