ExActor.Delegator

Provides delegate_to/2 macro that can be used to simplify cases when call/cast operations delegate to another module.

Source

Summary

delegate_to(target_module, opts)

Creates wrapper operations around the target_module

Macros

delegate_to(target_module, opts)

Creates wrapper operations around the target_module.

For example:

defmodule HashDictServer do
  use ExActor.GenServer
  import ExActor.Delegator

  defstart start_link, do: initial_state(HashDict.new)

  delegate_to HashDict do
    query get/2
    trans put/3
  end
end

This is the same as:

defmodule HashDictServer do
  use ExActor.GenServer

  defstart start_link, do: initial_state(HashDict.new)

  defcall get(k), state: state do
    HashDict.get(state, k)
    |> reply
  end

  defcast put(k, v), state:state do
    HashDict.put(state, k, v)
    |> new_state
  end
end
Source