diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-15 07:13:40 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-15 07:13:40 +0000 |
commit | 9f5a9aa35f1fa252a99498dc464677c968e694ba (patch) | |
tree | 8be0806c32f3426a66d9cf301d12c12aa8364e95 | |
parent | fb0673f5ad7cf3fc54f922f3215be0b0107de29b (diff) | |
download | rails-9f5a9aa35f1fa252a99498dc464677c968e694ba.tar.gz rails-9f5a9aa35f1fa252a99498dc464677c968e694ba.tar.bz2 rails-9f5a9aa35f1fa252a99498dc464677c968e694ba.zip |
Factor out checks for duplicable objects. Closes #9333.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7908 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb | 7 |
2 files changed, 3 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index ff0809676f..67a0299490 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2205,13 +2205,7 @@ module ActiveRecord #:nodoc: 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 diff --git a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb index 42ff1d7d54..e6b8e3ae90 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb @@ -74,13 +74,10 @@ module ActiveRecord @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 |