MethodMissing
Switched to Elixir and missed method_missing functionality in other languages?
This package is for you! It implements method_missing which you can bring into any other module!
Usage
defmodule Dog do
use MethodMissing
def method_missing(func, _args) do
func
|> Atom.to_string()
|> case do
"bark" -> "WOOF"
_ -> "?"
end
end
end
Dog.bark()
> "WOOF"
Dog.meow()
> "?"
Installation
If available in Hex, the package can be installed as:
-
Add
method_missingto your list of dependencies inmix.exs:
```elixir
def deps do
[{:method_missing, "~> 0.1.0"}]
end
```-
Ensure
method_missingis started before your application:
```elixir
def application do
[applications: [:method_missing]]
end
```