Fastfwd v0.1.0 Fastfwd.Modules View Source

Interact with Fastfwd-compatible modules - find, filter, build maps.

Link to this section Summary

Functions

Lists all modules, whether or not they are using Fastfwd

Find the first module that has the specified tag

Lists all modules in a module namespace (with names under the module name)

Filters a list of modules to only include those under a particular namespace

Build a map of tags to modules, without duplicated tags

List all tags found in a collection of modules

Lists all modules with the specified behaviour

Filters a list of modules to only include those with the specified behaviour

Find all modules that have the specified tag

Find modules that have tags (any tags at all)

Link to this section Functions

Lists all modules, whether or not they are using Fastfwd.

Returns a list of module names, including both Elixir style and Erlang atoms.

Examples

iex> Fastfwd.Modules.all |> List.first()
:io
Link to this function

find(modules, tag, default \\ nil) View Source
find([module()], atom(), nil | module()) :: module()

Find the first module that has the specified tag.

Returns a single module name.

Examples

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

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

Lists all modules in a module namespace (with names under the module name)

Returns a list of module names

Examples

iex> Fastfwd.Modules.in_namespace(Icecream)
[Icecream.Pistachio, Icecream.Spoon, Icecream.Chocolate, Icecream.ShavedIce, Icecream.Strawberry, Icecream.DoubleChocolate]
Link to this function

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

Filters a list of modules to only include those under a particular namespace

Returns filtered list of modules

Examples

iex> module_list = [Icecream.Pistachio, FrozenYogurt.FullCellphoneBattery, Icecream.Chocolate]
iex> Fastfwd.Modules.in_namespace(module_list, Icecream)
[Icecream.Pistachio, Icecream.Chocolate]
Link to this function

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

Build a map of tags to modules, without duplicated tags.

Returns a map of atoms to module names.

Examples

iex> modules_list = [Icecream.Pistachio, Icecream.Spoon, Icecream.Chocolate, Icecream.DoubleChocolate]
iex> Fastfwd.Modules.routes(modules_list)
%{
  pistachio: Icecream.Pistachio,
  chocolate: Icecream.DoubleChocolate,
  double_chocolate: Icecream.DoubleChocolate,
}
Link to this function

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

List all tags found in a collection of modules

Returns a list of atoms Returns a list of atoms

Examples

iex> modules_list = [Icecream.Pistachio, Icecream.Spoon, Icecream.Chocolate]
iex> Fastfwd.Modules.tags(modules_list)
[:pistachio, :chocolate]
Link to this function

with_behaviour(behaviour) View Source
with_behaviour(module()) :: [module()]

Lists all modules with the specified behaviour.

Returns a list of module names

Examples

iex> Fastfwd.Modules.with_behaviour(Fastfwd.Behaviours.Sender)
[Icecream]
Link to this function

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

Filters a list of modules to only include those with the specified behaviour

Returns filtered list of modules

Examples

iex> module_list = [Icecream.Pistachio, Icecream.Spoon, Icecream.Chocolate, Icecream.ShavedIce, Icecream.Strawberry, Icecream.DoubleChocolate]
iex> Fastfwd.Modules.with_behaviour(module_list, Fastfwd.Behaviours.Receiver)
[Icecream.Pistachio, Icecream.Chocolate, Icecream.ShavedIce, Icecream.Strawberry, Icecream.DoubleChocolate]
Link to this function

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

Find all modules that have the specified tag.

Tags are not necessarily unique - more than one module may have the same tag.

Returns a filtered list of modules

Examples

iex> module_list = [Icecream.Pistachio, Icecream.Spoon, Icecream.Chocolate, Icecream.ShavedIce, Icecream.Strawberry, Icecream.DoubleChocolate]
iex> Fastfwd.Modules.with_tag(module_list, :chocolate)
[Icecream.Chocolate, Icecream.DoubleChocolate]
Link to this function

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

Find modules that have tags (any tags at all)

Returns a filtered list of modules

Examples

iex> module_list = [Icecream.Pistachio, Icecream.Spoon]
iex> Fastfwd.Modules.with_tags(module_list)
[Icecream.Pistachio]