aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-02-11 21:02:17 +0000
committerMichael Koziarski <michael@koziarski.com>2008-02-11 21:02:17 +0000
commit873939013455135dfe751156c7f8c7ad6fbe6b59 (patch)
tree60805d9b70d2307edd020887d838272e76efe1dc /activerecord
parent081eed352fb7c16cbe1a18e13d032aa3512b04cd (diff)
downloadrails-873939013455135dfe751156c7f8c7ad6fbe6b59.tar.gz
rails-873939013455135dfe751156c7f8c7ad6fbe6b59.tar.bz2
rails-873939013455135dfe751156c7f8c7ad6fbe6b59.zip
Avoid cloning in Base#attributes_before_typecast. Closes #11077 [juanjo.bazan]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8858 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/base.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 642a7e2b96..cd33c8891c 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -2088,7 +2088,7 @@ module ActiveRecord #:nodoc:
# The extent of a "deep" clone is application-specific and is therefore
# left to the application to implement according to its need.
def clone
- attrs = self.attributes_before_type_cast
+ attrs = clone_attributes(:read_attribute_before_type_cast)
attrs.delete(self.class.primary_key)
record = self.class.new
record.send :instance_variable_set, '@attributes', attrs
@@ -2236,9 +2236,13 @@ module ActiveRecord #:nodoc:
end
end
- # Returns a hash of cloned attributes before typecasting and deserialization.
+ # Returns a hash of attributes before typecasting and deserialization.
def attributes_before_type_cast
- clone_attributes :read_attribute_before_type_cast
+ attrs = {}
+ self.attribute_names.each do |name|
+ attrs[name]=read_attribute_before_type_cast(name)
+ end
+ attrs
end
# Format attributes nicely for inspect.