Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 9f5a9aa35f1fa252a99498dc464677c968e694ba 1 parent fb0673f
@jeremy jeremy authored
View
8 activerecord/lib/active_record/base.rb
@@ -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
View
7 activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.