Skip to content

Commit 8963db2

Browse files
committed
Add a module to be use'd to define entrypoints
1 parent fa1d4d4 commit 8963db2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/fun_with_flags/entry_point.ex

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
defmodule FunWithFlags.EntryPoint do
2+
@moduledoc """
3+
Defines an entry point to query feature flags.
4+
5+
## Example
6+
7+
defmodule MyApp.Flags do
8+
use FunWithFlags.EntryPoint
9+
end
10+
11+
MyApp.Flags.enabled?(:foo)
12+
13+
"""
14+
15+
@doc false
16+
defmacro __using__(opts) do
17+
quote bind_quoted: [opts: opts] do
18+
@behaviour FunWithFlags.EntryPoint
19+
20+
# TODO: add what's currently in the top module.
21+
end
22+
end
23+
24+
@doc """
25+
An entry point must define this callback to provide its configuration.
26+
27+
This function is supposed to retrieve any runtime config (e.g. ENV vars) and
28+
return it as a keyword list.
29+
"""
30+
@callback config() :: {:ok, Keyword.t()}
31+
end

0 commit comments

Comments
 (0)