-
Notifications
You must be signed in to change notification settings - Fork 623
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
Container for Money of different currencies #770
Comments
@hmiller-mykey this is a very interesting requirement and I see how that would make sense in some cases. I haven't hard to deal with this so I don't know if any plugins exist, however this shouldn't be hard to implement yourself. If you want to utilise the |
@antstorm This is good stuff. That is how we are planning to implement it. |
I suggest not to override default implementation, but define separate class like PS. You can define internal store like this |
@hmiller-mykey makes perfect sense to make it public. There's a good chance other people might need a similar solution. Also @printercu has a really good point of not overriding the default implementation as it normally leads to bugs and confusion. The only problem is you won't be able to use it as a drop-in replacement, but it's all for the greater good. |
How can it be a drop-in replacement, if it would return different result type? |
@printercu depends on the interface of the result type (duck type). It probably won't be 100% compatible, but a good part of it can be |
I have began implementing this. I also made I also need to create a I will keep updating this as I make progress. If anyone has suggestions feel free to suggest to me. |
@hmiller-mykey sounds great! Btw, why do you need an adopted It would also be useful if you could describe your use cases in a bit more detail. |
I misspoke in my previous post when I said I need to create a |
Hello!
Apologies if this is the wrong place to ask this question.
I'm looking for guidance with dealing with multiple currencies.
I have a unique constraint where I always want to keep
Money
of different currency separate(Money
should never be exchanged). Additionally I want to be able to perform math operations onMoney
with different currency, and have the resultant object that contains each currency seperate.For example:
Basically what I need is a container object that lets me perform operations with different currency Money, but keeps them separate.
I haven't been able to find any gems that do something like this.
Has anyone had any experience with this?
Is there some gem that does this that I cannot find?
Thank you!
The text was updated successfully, but these errors were encountered: