Permalink
Browse files

Factor out checks for duplicable objects. Closes #9333.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7908 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
jeremy committed Oct 15, 2007
1 parent fb0673f commit 9f5a9aa35f1fa252a99498dc464677c968e694ba
@@ -2205,13 +2205,7 @@ def clone_attributes(reader_method = :read_attribute, attributes = {})
def clone_attribute_value(reader_method, attribute_name)
value = send(reader_method, attribute_name)
-
- case value
- when nil, Fixnum, true, false
- value
- else
- value.clone
- end
+ value.duplicable? ? value.clone : value
rescue TypeError, NoMethodError
value
end
@@ -74,13 +74,10 @@ def cache_sql(sql)
@query_cache[sql] = yield
end
- case result
- when Array
+ if Array === result
result.collect { |row| row.dup }
- when nil, Fixnum, Float, true, false
- result
else
- result.dup
+ result.duplicable? ? result.dup : result
end
rescue TypeError
result

0 comments on commit 9f5a9aa

Please sign in to comment.