overture8 / mangoex

Elixir wrapper for the MangoPay API
3 stars 3 forks source link

Enable runtime configuration of `api_base` (#1) #15

Closed artmoni closed 7 years ago

artmoni commented 7 years ago

It is very common to want to be able to configure a library based on the runtime environment. For instance, use the mangopay sandbox in staging, but not in production.

By using a module attribute to store the configuration in the module, we bind it to a compile-time value.

This commit removes the module variable, calling Application.fetch_env!/2 every time we build a url. This should not impact performance (this call is very cheap), and lets clients of the library set whatever value they want at runtime.

overture8 commented 7 years ago

Thanks for this.