diff options
author | claudiob <claudiob@gmail.com> | 2014-11-28 18:28:07 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-04 15:54:20 -0300 |
commit | 7926ab1004d2ec9118516445d32c75c9aaacba79 (patch) | |
tree | 85b919ef66e1b3244d520e75dc97756aa37a153b /activesupport | |
parent | b2bb2a462f8950522688e8e0d87a7d32a5863438 (diff) | |
download | rails-7926ab1004d2ec9118516445d32c75c9aaacba79.tar.gz rails-7926ab1004d2ec9118516445d32c75c9aaacba79.tar.bz2 rails-7926ab1004d2ec9118516445d32c75c9aaacba79.zip |
Remove hack to support BigDecimal in Ruby 1.9
Now that Rails requires Ruby >= 2.0, there is no need to check whether
`BigDecimal` exists or not.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/duplicable.rb | 13 | ||||
-rw-r--r-- | activesupport/test/core_ext/object/duplicable_test.rb | 11 |
2 files changed, 3 insertions, 21 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/duplicable.rb b/activesupport/lib/active_support/core_ext/object/duplicable.rb index 665cb0f96d..78b0536491 100644 --- a/activesupport/lib/active_support/core_ext/object/duplicable.rb +++ b/activesupport/lib/active_support/core_ext/object/duplicable.rb @@ -78,17 +78,8 @@ end require 'bigdecimal' class BigDecimal - # Needed to support Ruby 1.9.x, as it doesn't allow dup on BigDecimal, instead - # raises TypeError exception. Checking here on the runtime whether BigDecimal - # will allow dup or not. - begin - BigDecimal.new('4.56').dup - - def duplicable? - true - end - rescue TypeError - # can't dup, so use superclass implementation + def duplicable? + true end end diff --git a/activesupport/test/core_ext/object/duplicable_test.rb b/activesupport/test/core_ext/object/duplicable_test.rb index 8cc39ae7b9..d37f4bd0d8 100644 --- a/activesupport/test/core_ext/object/duplicable_test.rb +++ b/activesupport/test/core_ext/object/duplicable_test.rb @@ -6,16 +6,7 @@ require 'active_support/core_ext/numeric/time' class DuplicableTest < ActiveSupport::TestCase RAISE_DUP = [nil, false, true, :symbol, 1, 2.3, method(:puts)] ALLOW_DUP = ['1', Object.new, /foo/, [], {}, Time.now, Class.new, Module.new] - - # Needed to support Ruby 1.9.x, as it doesn't allow dup on BigDecimal, instead - # raises TypeError exception. Checking here on the runtime whether BigDecimal - # will allow dup or not. - begin - bd = BigDecimal.new('4.56') - ALLOW_DUP << bd.dup - rescue TypeError - RAISE_DUP << bd - end + ALLOW_DUP << BigDecimal.new('4.56') def test_duplicable RAISE_DUP.each do |v| |