Like @theangryangel said, take a look at defdelegate though personally I think that
defdelegate should only be used to delegate t methods and functions from external packages.
defmodule Novistore.Accounts.Authentication do
Check the password against the password_hash
defdelegate check_password(password, password_hash), to: Comeonin.Bcrypt, as: :checkpw
Dummy check password
defdelegate dummy_check_password, to: Comeonin.Bcrypt, as: :dummy_checkpw
Hash the password
defdelegate hash_password(password), to: Comeonin.Bcrypt, as: :hashpwsalt
The above example allows me to switch out Bcrypt for Aragon2 in the future (if needed) without having to refactor the entire app.
I really like this article http://devonestes.herokuapp.com/a-proposal-for-context-rules by @devonestes for when you have to deal with large contexts.
We’ve adapted his idea’s at Novistore and I’m really happy with it.