Skip to content

Commit

Permalink
Merge pull request RubyMoney#325 from joshhepworth/feature-comparisio…
Browse files Browse the repository at this point in the history
…n-deprecation

Show deprecation warning in comparisions
  • Loading branch information
semmons99 committed Oct 1, 2013
2 parents 8a519c2 + 337cd75 commit 6bf554d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ John Duff
John Gakos
Josh Delsman
Joshua Clayton
Josh Hepworth
Kaleem Ullah
Kenichi Kamiya
Kenn Ejima
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Add :rounded_infinite_precision option to .format
- Changed the New Taiwan Dollar symbol position from after the amount to before the amount.
- Passing a Money instance to the Money constructor will obtain a new Money object with the same property values as the original
- Add deprecation warning to comparators

## 5.1.1

Expand Down
2 changes: 2 additions & 0 deletions lib/money/money/arithmetic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def -@
# Money.new(100) == Money.new(100) #=> true
def ==(other_money)
if other_money.respond_to?(:to_money)
Money.deprecate "as of Money 6.1.0 you must `require 'money/core_extension'` to compare Money to core classes." unless other_money.is_a? Money
other_money = other_money.to_money
fractional == other_money.fractional && currency == other_money.currency
else
Expand All @@ -45,6 +46,7 @@ def eql?(other_money)

def <=>(other_money)
if other_money.respond_to?(:to_money)
Money.deprecate "as of Money 6.1.0 you must `require 'money/core_extension'` to compare Money to core classes." unless other_money.is_a? Money
other_money = other_money.to_money
if fractional == 0 || other_money.fractional == 0 || currency == other_money.currency
fractional <=> other_money.fractional
Expand Down

0 comments on commit 6bf554d

Please sign in to comment.