diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-19 17:24:24 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-19 17:24:24 -0700 |
commit | fa362ffa212d42e0357cd77768db8ec681106755 (patch) | |
tree | 74d7bc957ca2e3a02288f8f478dba080de649ce5 | |
parent | 245098077dfb6f90931019c59741f4e17f5589fd (diff) | |
parent | 97338d581484521263f066db3e79775a5c311e83 (diff) | |
download | rails-fa362ffa212d42e0357cd77768db8ec681106755.tar.gz rails-fa362ffa212d42e0357cd77768db8ec681106755.tar.bz2 rails-fa362ffa212d42e0357cd77768db8ec681106755.zip |
Merge pull request #7710 from guilleiguaran/refactor-ar-attributes-method
AR::Base#attributes= is just an alias for AR::Base#assign_attributes
-rw-r--r-- | activerecord/lib/active_record/attribute_assignment.rb | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/attribute_assignment.rb b/activerecord/lib/active_record/attribute_assignment.rb index ccc61ec5d3..fa8c5ac95c 100644 --- a/activerecord/lib/active_record/attribute_assignment.rb +++ b/activerecord/lib/active_record/attribute_assignment.rb @@ -5,20 +5,12 @@ module ActiveRecord include ActiveModel::DeprecatedMassAssignmentSecurity include ActiveModel::ForbiddenAttributesProtection - # Allows you to set all the attributes at once by passing in a hash with keys - # matching the attribute names (which again matches the column names). + # Allows you to set all the attributes by passing in a hash of attributes with + # keys matching the attribute names (which again matches the column names) # # If the passed hash responds to permitted? method and the return value # of this method is false an ActiveModel::ForbiddenAttributesError exception # is raised. - def attributes=(new_attributes) - return unless new_attributes.is_a?(Hash) - - assign_attributes(new_attributes) - end - - # Allows you to set all the attributes by passing in a hash of attributes with - # keys matching the attribute names (which again matches the column names) def assign_attributes(new_attributes) return if new_attributes.blank? @@ -42,6 +34,8 @@ module ActiveRecord assign_multiparameter_attributes(multi_parameter_attributes) unless multi_parameter_attributes.empty? end + alias attributes= assign_attributes + private def _assign_attribute(k, v) |