View Source Bonfire.Common.ContextModule behaviour (Bonfire v0.9.11-social-beta.6)

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

context_module()

(optional)
@callback context_module() :: any()

Declares a context module

query_module()

(optional)
@callback query_module() :: atom()

Points to the related queries module

schema_module()

(optional)
@callback schema_module() :: atom()

Points to the related schema module

Functions

apply_error(error, args)

context_function_error(error, args)

context_module(query)

Get a context identified by schema

context_module!(query)

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

context_modules(modules)

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

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

linked_query_modules()

linked_schema_modules()

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

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

maybe_context_module(query)

modules()

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

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