View Source Bonfire.Common.ContextModule behaviour (Bonfire v0.9.10-classic-beta.156)

Find a context or query module via its schema, backed by a global cache of known modules.

Summary

Callbacks

Declares a context module

Points to the related queries module

Points to the related schema module

Functions

Get a context identified by schema

Look up a context, throw :not_found if not found.

Look up many contexts at once, throw :not_found if any of them are not found

Given an object or schema module name, run a function on the associated context module. TODO: refactor to re-use Utils.maybe_apply?

Callbacks

@callback context_module() :: any()

Declares a context module

@callback query_module() :: atom()

Points to the related queries module

@callback schema_module() :: atom()

Points to the related schema module

Functions

Link to this function

apply_error(error, args)

View Source
Link to this function

context_function_error(error, args)

View Source

Get a context identified by schema

Look up a context, throw :not_found if not found.

Link to this function

context_modules(modules)

View Source
@spec context_modules([binary() | atom()]) :: [binary()]

Look up many contexts at once, throw :not_found if any of them are not found

Link to this function

maybe_apply(object_schema_or_context, fun, args \\ [], opts \\ [fallback_fun: &apply_error/2])

View Source

Given an object or schema module name, run a function on the associated context module. TODO: refactor to re-use Utils.maybe_apply?

Link to this function

maybe_context_module(query)

View Source
@spec modules() :: [atom()]

Callback implementation for Bonfire.Common.ExtensionBehaviour.modules/0.