Add Money.with_bank for Dynamic Currency Stores#713
Add Money.with_bank for Dynamic Currency Stores#713pranavbabu wants to merge 6 commits intoRubyMoney:mainfrom
Conversation
|
@pranavbabu would you mind rebasing your branch with |
Github did merge automatically when I synced my fork ;) |
yukideluxe
left a comment
There was a problem hiding this comment.
Hello @pranavbabu, thanks for your contribution! I have one question and one concern about this 😊
- Why did you add this change to
money-railsinstead of tomoney? I have a feeling this isn’t Rails-specific, so it seems like it might belong in themoneygem instead, but I might be missing something, I’m still learning! - I already had some concerns about this, but after reviewing RubyMoney/money#1128, I’m almost certain this solution won’t be thread-safe. I think it should be implemented similarly to how
Money.with_rounding_modeis done usingThread.current. Could you maybe add some tests like the ones here? 🙏🏻
|
Hey @yukideluxe, I added it to this lib just because we had this fix in our company fork for a very long time , I've never thought about money gem itself since we use rails 😅 so you might be correct and I should address it in another gem, your second point is actually really useful, we had some weird bugs where bank was not set and we had currency exchange problems , so now I know why 🙈 big thanks , I'm gonna close this one in favour of new PR to money gem , after vacation 🤗 |
Great! thanks! I'll keep an eye for your PR in the other repo 👀 |
|
Closing in favour of #this PR |
This PR introduces the
Money.with_bankmethod, allowing developers to assign different currency stores (banks) dynamically within a scoped block. This is particularly useful for loading custom exchange rates per user session.Key Changes