An Elixir library that implements prototype inheritance for dynamic function calling over a chain of modules. These prototypes can be user-defined struct modules or any other modules.
To specify a module's prototype module, implement the __prototype__/0 function like so:
defmoduleYourModuledodef__prototype__,do: AnyOtherModuleendThen to call functions wherever they are found up the prototype chain you might:
casePrototype.apply(YourModule,:function_name,["argument","list"])do{:ok,return_value,_meta}->return_value,{:missing_fun,_function_name,_args,_meta}->{:error,"function not found"}endWhere _meta contains tracing metadata about the call chain that executed.
As you might suspect, if the function cannot be found in any of the modules
then the result is a :missing_fun tuple because it's not very fun to have
multiple attempts to call a function fail!
This package can be installed by adding prototype to
your list of dependencies in mix.exs:
defdepsdo[{:prototype,"~> 1.0.0-alpha"}]endIf you use this library and have suggestions for how to make it better, please file an issue.