Skip to content

Commit

Permalink
Revert "Drop support for initialization with another money object."
Browse files Browse the repository at this point in the history
  • Loading branch information
elfassy committed Apr 11, 2024
1 parent d2b1523 commit 241365b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
shopify-money (2.0.0)
shopify-money (2.1.0)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 2 additions & 0 deletions lib/money/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module Helpers
def value_to_decimal(num)
value =
case num
when Money
num.value
when BigDecimal
num
when nil, 0, ''
Expand Down
4 changes: 2 additions & 2 deletions spec/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
let (:amount) { BigDecimal('1.23') }
let (:money) { Money.new(amount) }

it 'raises when provided with a money object' do
expect { subject.value_to_decimal(money) }.to raise_error(ArgumentError)
it 'returns the value of a money object' do
expect(subject.value_to_decimal(money)).to eq(amount)
end

it 'returns itself if it is already a big decimal' do
Expand Down

0 comments on commit 241365b

Please sign in to comment.