Skip to content

Commit 7fceacc

Browse files
committed
Replace deprecated BigDecimal.new() calls with BigDecimal()
After upgrading to ruby 2.6.1, our application started logging this warning: ``` warning: BigDecimal.new is deprecated; use BigDecimal() method instead. ``` which was being emitted from roxml-4.0.0/lib/roxml/definition.rb:179 So, in this commit I've replaced the deprecated `BigDecimal.new` invocations with invoking the `BigDecimal` method as recommended.
1 parent 848f1a1 commit 7fceacc

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎lib/roxml/definition.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def self.block_shorthands
176176
CORE_BLOCK_SHORTHANDS.tap do |blocks|
177177
blocks.reverse_merge!(BigDecimal => lambda do |val|
178178
all(val) do |v|
179-
BigDecimal.new(v) unless v.blank?
179+
BigDecimal(v) unless v.blank?
180180
end
181181
end) if defined?(BigDecimal)
182182

‎spec/definition_spec.rb‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ def self.from_xml(val)
281281
it_should_behave_like "block shorthand type declaration"
282282

283283
it "should translate text to decimal numbers" do
284-
expect(@definition.blocks.first['3']).to eq(BigDecimal.new("3.0"))
285-
expect(@definition.blocks.first['0.3']).to eq(BigDecimal.new("0.3"))
284+
expect(@definition.blocks.first['3']).to eq(BigDecimal("3.0"))
285+
expect(@definition.blocks.first['0.3']).to eq(BigDecimal("0.3"))
286286
end
287287

288288
# Ruby behavior of BigDecimal changed in 2.4, this test is not valid on older rubies
@@ -293,12 +293,12 @@ def self.from_xml(val)
293293
end
294294

295295
it "should extract what it can" do
296-
expect(@definition.blocks.first['11sttf']).to eql(BigDecimal.new("11.0"))
296+
expect(@definition.blocks.first['11sttf']).to eql(BigDecimal("11.0"))
297297
end
298298

299299
context "when passed an array" do
300300
it "should translate the array elements to integer" do
301-
expect(@definition.blocks.first.call(["12.1", "328.2"])).to eq([BigDecimal.new("12.1"), BigDecimal.new("328.2")])
301+
expect(@definition.blocks.first.call(["12.1", "328.2"])).to eq([BigDecimal("12.1"), BigDecimal("328.2")])
302302
end
303303
end
304304
end

0 commit comments

Comments
 (0)