Permalink
Browse files

Avoid cloning in Base#attributes_before_typecast. Closes #11077 [juan…

…jo.bazan]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8858 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
NZKoz committed Feb 11, 2008
1 parent 081eed3 commit 873939013455135dfe751156c7f8c7ad6fbe6b59
Showing with 7 additions and 3 deletions.
  1. +7 −3 activerecord/lib/active_record/base.rb
@@ -2088,7 +2088,7 @@ def destroy
# 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 @@ def attributes(options = nil)
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.

0 comments on commit 8739390

Please sign in to comment.