Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor extension discovery and add base module for all extensions #335

Merged
merged 2 commits into from
Nov 20, 2019

Conversation

danschultzer
Copy link
Collaborator

@danschultzer danschultzer commented Nov 20, 2019

Resolves #329

This may supersede #333

With this PR a base module is now expected in an extension that will clearly describe what the extension supports. This should prevent pretty much all Code.ensure_compiled?/1 calls, but is still backwards compatible.

For extensions missing the base module a warning will be printed with no MyCustomModule base module to check for ["Ecto", "Schema"] support found, please use Pow.Extension.Base to implement it).

A base module would look like this:

defmodule PowEmailConfirmation do
  @moduledoc false
  use Pow.Extension.Base

  @impl true
  def ecto_schema?(), do: true

  @impl true
  def phoenix_controller_callbacks?(), do: true

  @impl true
  def phoenix_router?(), do: true

  @impl true
  def phoenix_messages?(), do: true
end

@danschultzer
Copy link
Collaborator Author

As discussed in #333 (comment) I think it would be wise to require explicitly passing extensions, and maybe include the suggestion in #329 (comment) to have a test helper that can verify the extensions has been correctly set up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider reducing ensure_compiled checks
2 participants