Fastfwd v0.1.0 Fastfwd View Source

Toolkit for quickly building simple module proxies, adapters, plugins, facades, etc.

Link to this section Summary

Functions

Finds the first appropriate module from a list of modules for the supplied tag

Returns a list of all modules within a module namespace

Returns a list of all modules within a module namespace, filtered by behaviour

Finds all modules for the first application and preloads them, making them visible to Fastfwd

Finds all modules for listed applications and preloads them, making them visible to Fastfwd

Returns a map of tags and modules

Returns a list of all modules implementing a Sender behaviour (Fastfwd.Behaviours.Sender)

Finds all tags used by receivers in a list of modules

Link to this section Functions

Link to this function

find(modules, tag) View Source
find([module()], atom()) :: [module()]

Finds the first appropriate module from a list of modules for the supplied tag

Returns the module

Examples

iex> modules = Fastfwd.modules(Icecream)
iex> Fastfwd.find(modules, :chocolate)
Icecream.Chocolate
Link to this function

fwd(modules, tag, function_name, params) View Source

Link to this function

modules(namespace) View Source
modules(module()) :: [module()]

Returns a list of all modules within a module namespace

This will include any module with within the namespace, including those that lack a required behaviour.

Examples

iex> Fastfwd.modules(Icecream)
[Icecream.Pistachio, Icecream.Spoon, Icecream.Chocolate, Icecream.ShavedIce, Icecream.Strawberry, Icecream.DoubleChocolate]

In this example Icecream.Spoon is not a receiver, and has no receiver tags.

Link to this function

modules(namespace, behaviour) View Source
modules(module(), module()) :: [module()]

Returns a list of all modules within a module namespace, filtered by behaviour.

Examples

iex> Fastfwd.modules(Icecream, Fastfwd.Behaviours.Receiver)
[Icecream.Pistachio, Icecream.Chocolate, Icecream.ShavedIce, Icecream.Strawberry, Icecream.DoubleChocolate]

Icecream.Spoon lacks receiver behaviour so it has been excluded.

Link to this function

preload() View Source
preload() :: {:ok, [atom()]} | {:error, String.t()}

Finds all modules for the first application and preloads them, making them visible to Fastfwd.

If a module has not been loaded it might not be detected as a Fastfwd sender - in some environments Elixir will only load a module when it first accessed, and so modules designed to be accessed by Fastfwd may not be ready.

Modules using the Fastfwd.Sender module will auto-load their receiver modules, but you may want to manually preload modules if you are using Fastfwd to build something more bespoke.

If no applications are specified then Fastfwd will attempt to search the first application found, assuming it to be the current project.

Examples

iex> Fastfwd.preload()
{:ok, [:my_app]}
Link to this function

preload(list_of_applications) View Source
preload([atom()]) :: {:ok, [atom()]} | {:error, String.t()}

Finds all modules for listed applications and preloads them, making them visible to Fastfwd.

If a module has not been loaded it might not be detected as a Fastfwd sender - in some environments Elixir will only load a module when it first accessed, and so modules designed to be accessed by Fastfwd may not be ready.

Modules using the Fastfwd.Sender module will auto-load their receiver modules, but you may want to manually preload modules if you are using Fastfwd to build something more bespoke.

If :all is specified then Fastfwd will attempt to search all applications.

Examples

iex> Fastfwd.preload(:my_app)
{:ok, [:my_app]}

iex> Fastfwd.preload([:my_app, :my_app_ee, :extra_plugins])
{:ok, [:my_app, :my_app_ee, :extra_plugins]}

iex> Fastfwd.preload(:all)
{:ok, [:my_app, :fastfwd, :fastglobal, :syntax_tools, :benchee, :deep_merge, :logger, :hex, :inets, :ssl, :public_key, :asn1, :crypto, :mix, :iex, :elixir, :compiler, :stdlib, :kernel]}
Link to this function

routes(modules) View Source
routes([module()]) :: map()

Returns a map of tags and modules

Examples

iex> Fastfwd.modules(Icecream) |> Fastfwd.routes()
%{chocolate: Icecream.DoubleChocolate, double_chocolate: Icecream.DoubleChocolate, pistachio: Icecream.Pistachio, strawberry: Icecream.Strawberry}

Returns a list of all modules implementing a Sender behaviour (Fastfwd.Behaviours.Sender)

Examples

iex> Fastfwd.senders()
[Icecream]
Link to this function

tags(modules) View Source
tags([module()]) :: [atom()]

Finds all tags used by receivers in a list of modules

Returns a list of tags as atoms

Examples

iex> modules = Fastfwd.modules(Icecream)
iex> Fastfwd.tags(modules)
[:pistachio, :chocolate, :strawberry, :chocolate, :double_chocolate]