| Class | ActiveRecord::Base |
| In: |
lib/acts_as_eav_model.rb
|
| Parent: | Object |
Overrides ActiveRecord::Base#attributes=
Because in version >=2.2.2 of ActiveRecord the behaviour in the attributes have been changed to throw a NoMethodError if the AR object don‘t respond to an attribute setter, we could not use method missing to allow for our entity-attribute-value behaviour.
# File lib/acts_as_eav_model.rb, line 492
492: def attributes=(new_attributes, guard_protected_attributes = true)
493: return if new_attributes.nil?
494: attributes = new_attributes.dup
495: attributes.stringify_keys!
496:
497: multi_parameter_attributes = []
498: attributes = remove_attributes_protected_from_mass_assignment(attributes) if guard_protected_attributes
499:
500: attributes.each do |k, v|
501: if k.include?("(")
502: multi_parameter_attributes << [ k, v ]
503: else
504: send("#{k}=""#{k}=", v)
505: end
506: end
507:
508: assign_multiparameter_attributes(multi_parameter_attributes)
509: end