ericmj / decimal

Arbitrary precision decimal arithmetic

Home Page:https://hexdocs.pm/decimal/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to globally set context? Eg.: config.exs

fschuindt opened this issue · comments

Besides the question in the title, what's the recommended way to set my context across a Mix app?

Most precisely a "two app" umbrella which both uses Decimal all over.

I've tried application.ex and config.exs. How do you feel about anyone trying to contribute to a Mix config friendly approach on it?

Thank you.

No, there is no way to do that currently.

I don't think adding global configuration to a pure library is the best thing to do. Changing the defaults can have unintended side effects on other libraries, such as your dependencies. I would recommend setting a config for your own application and pass that to Decimal.with_context.

@ericmj Good point. I think I will tweak my code a bit in order to run functions with context. It's kinda strange to have to pass a context in every Decimal operation, but I believe it's the way to go.

Thank you.