Fact.Seam.Adapter behaviour (Fact v0.2.1)
View SourceBase behaviour module providing the "glue" between a specific Seam and its implementations.
This module handles:
- Resolving allowed and default implementations.
- Merging default, fixed, and supplied options for a given implementation.
- Initializing a seam instance (
Fact.Seam.Instance) with the correct configuration. - Generic dispatch to the underlying implementation via
__seam_call__/3.
Responsibilities
- Registry Interaction – Uses the seam's registry to resolve implementation modules and versions.
- Option Management – Combines fixed options, default options, and user-supplied options and normalizes them.
- Instance Creation – Produces a
%Fact.Seam.Instance{}struct that encapsulates the module and its initialized state. - Dispatch Helper – Provides
__seam_call__/3to call a function on the underlying seam instance cleanly.
Initialization
init/0– Initializes the default implementation.init/2– Initializes a specific implementation with optional custom options.from_config/1– Initializes a seam instance from a map-based configuration.
Option Normalization
The adapter ensures that only allowed options for a given implementation are used, and merges fixed options that cannot be overridden.
Summary
Functions
Generic dispatch
Callbacks
@callback allowed_impls() :: [{atom(), pos_integer()}]
@callback default_impl() :: {atom(), pos_integer()}
@callback default_options({atom(), pos_integer()}) :: map()
@callback fixed_options({atom(), pos_integer()}) :: map()
@callback normalize_options( {atom(), pos_integer()}, map() ) :: map()
@callback registry() :: module()