diff options
Diffstat (limited to 'activerecord/lib/active_record')
-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 |