From 97338d581484521263f066db3e79775a5c311e83 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Wed, 19 Sep 2012 19:19:11 -0500 Subject: AR::Base#attributes= is just an alias for AR::Base#assign_attributes --- activerecord/lib/active_record/attribute_assignment.rb | 14 ++++---------- 1 file 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) -- cgit v1.2.3