ex_shards v0.2.0 ExShards.Construct

This is an utility module, which provides a set of macros to inject functions from Erlang modules.

Summary

Macros

Injects exported functions from an Erlang module

Macros

inject(mod, opts \\ [])

Injects exported functions from an Erlang module.

By default, it injects all functions from the given module:

inject :lists

Alternatively, it allows you to pass pairs of name/arities to :except as a fine grained control on what to inject (or not):

inject :lists, except: [append: 1]

Besides, it allows you to pass only the name of the fuction(s) to :except, in order to exclude all function that matches with that name – no matter the arity. E.g.:

inject :lists, except: [:append]

This will exclude either :lists.append/1 and :lists.append/2.

Example

defmodule Utils do
  use ExShards.Construct

  # injects all exported functions in module `:lists`
  inject :lists

  # injects all exported functions in module `:maps` except:
  # `:maps.get/2`, `:maps.get/3` and `:maps.find/2`.
  inject :maps, except: [:get, find: 2]
end