Mau.FilterRegistry (mau v0.8.0)
View SourceDynamic filter registry that loads filters from module specs.
This registry automatically discovers filters by calling spec() functions on filter modules, providing better organization and discoverability.
Configuration
By default, uses compile-time module attributes for maximum performance. Enable runtime mode for user-defined filters:
config :mau, :enable_runtime_filters, true
Summary
Functions
Applies a filter to a value with the given arguments.
Returns a specification to start this module under a supervisor.
Gets a filter function by name.
Initializes the registry by loading all filters into state.
Starts the filter registry GenServer.
Types
Functions
@spec apply(filter_name(), any(), list()) :: {:ok, any()} | {:error, :filter_not_found | {:filter_error, any()}}
Applies a filter to a value with the given arguments.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get(filter_name()) :: {:ok, filter_mfa()} | {:error, :not_found}
Gets a filter function by name.
Examples
iex> {:ok, {module, function}} = Mau.FilterRegistry.get(:upper_case)
iex> is_atom(module) and is_atom(function)
true
iex> Mau.FilterRegistry.get(:unknown_filter)
{:error, :not_found}
Initializes the registry by loading all filters into state.
Starts the filter registry GenServer.