LazyContext
This library enables you to implement default functions in Phoenix contexts
See Usage for example usage.
Documentation
Documentation is available at https://hexdocs.pm/lazy_context
Installation
Add :lazy_context to your list of dependencies in mix.exs:
def deps do
[
{:lazy_context, "~> 0.1.5-dev"}
]
endConfiguration
Optionally set the repo for LazyContext config in your config/config.exs file:
config :lazy_context,
repo: YourApplication.RepoUsage
defmodule MyApp.Users do
@moduledoc """
The Accounts context.
"""
use LazyContext,
schema: User,
suffix: :user,
# this can be omitted if the repo was set in the context
repo: MyApp.Repo,
preloads: [:pets]
# functions can be overridden
def list_users() do
# custom code here
end
endTODO
- Tests
- Improve README
- Generate documentation
- Publish on hex.pm
- Allow custom pluralized function names
-
Improve error handling if
repoor other mandatory options not provided -
Enable
onlyandexceptoptions to specify which functions should be included