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

defimpl for maps #623

Open
mnussbaumer opened this issue Aug 11, 2021 · 0 comments
Open

defimpl for maps #623

mnussbaumer opened this issue Aug 11, 2021 · 0 comments

Comments

@mnussbaumer
Copy link

Hi,

can someone explain what is the idea behind having this on formatter.ex?

defimpl Bamboo.Formatter, for: Map do
  def format_email_address(invalid_address, _opts) do
    raise ArgumentError, """
    The format of the address was invalid. Got #{inspect(invalid_address)}.
    Expected a string, e.g. "foo@bar.com", a 2 item tuple {name, address}, or
    something that implements the Bamboo.Formatter protocol.
    Example:
    defimpl Bamboo.Formatter, for: MyApp.User do
      def format_email_address(user, _opts) do
        {user.name, user.email}
      end
    end
    """
  end
end

This introduces warnings and duplicated modules errors and it seems like it isn't doing anything that a non-existing defimpl would warn/error by itself?

Other than that, how can I create an implementation for the Map type?

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

No branches or pull requests

1 participant