-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from danschultzer/deprecate-context-base
Deprecate extension context base
- Loading branch information
Showing
7 changed files
with
18 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,15 @@ | ||
defmodule Pow.Extension.Ecto.Context.Base do | ||
@moduledoc """ | ||
Used for extensions to add helpers for user contexts. | ||
The macro will add two helper methods to the module: | ||
* `user_schema_mod/1` | ||
* `repo/1` | ||
## Usage | ||
defmodule MyPowExtension.Ecto.Context do | ||
use Pow.Extension.Ecto.Context.Base | ||
def my_custom_action(_config) do | ||
mod = user_schema_mod(config) | ||
repo = repo(config) | ||
# ... | ||
end | ||
end | ||
""" | ||
# TODO: Remove by 1.1.0 | ||
@moduledoc false | ||
alias Pow.Ecto.Context | ||
|
||
@doc false | ||
defmacro __using__(_opts) do | ||
quote do | ||
def user_schema_mod(config), do: Context.user_schema_mod(config) | ||
def repo(config), do: Context.repo(config) | ||
IO.warn("use #{unquote(__MODULE__)} is deprecated, please use methods in #{Context} instead") | ||
|
||
defdelegate user_schema_mod(config), to: Context | ||
defdelegate repo(config), to: Context | ||
end | ||
end | ||
end |