1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
claudiob 2014-11-28 18:28:07 -08:00 committed by Rafael Mendonça França
parent b2bb2a462f
commit 7926ab1004
2 changed files with 3 additions and 21 deletions

View file

@ -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

View file

@ -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|