No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
lib
test
.gitignore
README.md
mix.exs
mix.lock

README.md

Exporter

On the library side, you can specify functions and macros that the caller can use by default.

Examples

  defmodule MyModule do
    use Exporter, default: [a: 0, b: 1]

    def a, do: "a"
    def b(_), do: "b"
    def c, do: "c"

  end

  defmodule MyApp do
    use MyModule
    a()  # ok. default import
    b(1) # ok. default import
    c()  # error

    use MyModule, [c: 0]
    a()  # error
    b(1) # error
    c()  # ok
  end

  # allow override

  defmodule MyModule do

    use Exporter, default: [a: 0, b: 1]

    defmacro __using__(opt)  do
      ast = super(opt)
      quote do
        import Enum, only: [min: 1]
        unquote(ast)
      end
    end

  end

Installation

If available in Hex, the package can be installed by adding exporter to your list of dependencies in mix.exs:

def deps do
  [{:exporter, "~> 0.1.0"}]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/exporter.