Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced BigDecimal.new() with BigDecimal() #1937

Merged
merged 1 commit into from Dec 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/attribute_value.rb
Expand Up @@ -76,12 +76,12 @@ def format(obj)
end
when :l then value.map { |v| format(v) }
when :s then value
when :n then BigDecimal.new(value)
when :n then BigDecimal(value)
when :b then StringIO.new(value)
when :null then nil
when :bool then value
when :ss then Set.new(value)
when :ns then Set.new(value.map { |n| BigDecimal.new(n) })
when :ns then Set.new(value.map { |n| BigDecimal(n) })
when :bs then Set.new(value.map { |b| StringIO.new(b) })
when :es then Set.new
else
Expand Down
16 changes: 8 additions & 8 deletions gems/aws-sdk-dynamodb/spec/attribute_value_spec.rb
Expand Up @@ -79,7 +79,7 @@ def initialize(val)

# Ruby 2.4 changed the casing of BigDecimal's to_s value.
# We need to check in a case insensitive manner
big_decimal_value = value.marshal(BigDecimal.new("0.1E125"))
big_decimal_value = value.marshal(BigDecimal("0.1E125"))
expect(big_decimal_value.keys).to eq([:n])
expect(big_decimal_value[:n]).to match(/0.1E125/i)
end
Expand Down Expand Up @@ -201,7 +201,7 @@ def initialize(val)

it 'converts :ns to a set of big decimals (to preserve precision)' do
expect(value.unmarshal(ns: %w(123 456))).to eq(
Set.new([BigDecimal.new('123'), BigDecimal.new('456')]))
Set.new([BigDecimal('123'), BigDecimal('456')]))
end

it 'converts :bs to a set of binary values' do
Expand All @@ -217,9 +217,9 @@ def initialize(val)

it 'converts :n to big decimals' do
# supports integers, floats, and big decimals
expect(value.unmarshal(n: '123')).to eq(BigDecimal.new('123'))
expect(value.unmarshal(n: '12.34')).to eq(BigDecimal.new('12.34'))
expect(value.unmarshal(n: '0.1E125')).to eq(BigDecimal.new('0.1E125'))
expect(value.unmarshal(n: '123')).to eq(BigDecimal('123'))
expect(value.unmarshal(n: '12.34')).to eq(BigDecimal('12.34'))
expect(value.unmarshal(n: '0.1E125')).to eq(BigDecimal('0.1E125'))
end

it 'converts :s to a string' do
Expand Down Expand Up @@ -297,9 +297,9 @@ def initialize(val)
},
],
'scores' => [
BigDecimal.new('4.5'),
BigDecimal.new('5'),
BigDecimal.new('3.9'),
BigDecimal('4.5'),
BigDecimal('5'),
BigDecimal('3.9'),
nil,
'perfect'
]
Expand Down