From 873939013455135dfe751156c7f8c7ad6fbe6b59 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Mon, 11 Feb 2008 21:02:17 +0000 Subject: 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 --- activerecord/lib/active_record/base.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'activerecord') 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. -- cgit v1.2.3