Do not hardcode helper methods for specific currencies#1213
Do not hardcode helper methods for specific currencies#1213c960657 wants to merge 2 commits intoRubyMoney:mainfrom
Conversation
There was a problem hiding this comment.
I love the idea of simplifying the code and removing these special cases for certain currencies. 😍
However I’m not sure we want to encourage people to write their own shortcut methods and have to maintain this, knowing that adding methods this way could possibly break future needs.
I think I’d rather encourage people using the Turkish lira to use Money.new(1_00, "TRY") or 1.to_money("TRY") than to add a new Money.try(1) method.
|
Good point about But I tend to agree that such helpers are not the way to go. In a multi-currency application you would usually not use currency-specific method names. I would primarily use them in tests for better readability. But users can easily monkey-patch helpers for their preferred currencies. If helpers are deemed unnecessary, I think the existing helpers for USD, EUR and CAD should be deprecated and eventually removed. |
sunny
left a comment
There was a problem hiding this comment.
I like the idea of removing these methods from the docs and deprecating them.
I don’t mind the idea of introducing new shorthands such as .from_usd, from_cad, from_eur, etc for every currency. Since they are more generic and come with a prefix, it might be doable to have these methods available for every possible currency, too.
Instead of hardcoded support for four specific currencies (CAD, EUR, GBP, USD), allow users to decide which currencies to define helper methods for.