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
all()
View Source
all() :: [module()]
all() :: [module()]
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
find(modules, tag, default \\ nil) View Source
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
in_namespace(namespace) View Source
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]
in_namespace(modules, namespace) View Source
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]
routes(modules) View Source
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,
}
tags(modules) View Source
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]
with_behaviour(behaviour) View Source
Lists all modules with the specified behaviour.
Returns a list of module names
Examples
iex> Fastfwd.Modules.with_behaviour(Fastfwd.Behaviours.Sender)
[Icecream]
with_behaviour(modules, behaviour) View Source
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]
with_tag(modules, tag) View Source
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]
with_tags(modules) View Source
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]