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

Fix Email.address() typespec #570

Merged
merged 1 commit into from
Dec 24, 2020
Merged

Conversation

germsvel
Copy link
Collaborator

@germsvel germsvel commented Dec 23, 2020

What changed?

In #386, @evuez correctly pointed out that the Bamboo.Email.address() typespec shows String.t() | {String.t(), String.t()}. But no adapter actually supports the String.t() type.

Given that the code was introduced before the typespecs (and thus we can treat the code as the source of truth when in doubt), and since Bamboo.Email.get_address/1's explicit intent is to abstract the internal representation of email addresses in case Bamboo changes how it stores them:

Gets just the email address from a normalized email address.
Normalized email addresses are 2 item tuples {name, address}. This gets the address part of the tuple. Use this instead of calling elem(address, 1) so that if Bamboo changes how email addresses are represented your code will still work

-- From get_address/1 docs.

I think the correct change here is to remove the String.t() portion of the typespec rather than update the code to handle that typespec. In other words, I think we made a typo when introducing the typespec. So this PR would be merged instead of #386.

What changed?
============

In #386, evuez pointed out that
the `Bamboo.Email.address()` typespec shows `String.t() | {String.t(),
String.t()}`. But no adapter actually supports the `String.t()` type.

Given that the code was introduced [before the
typespecs](#150) (and thus we
can treat the code as the source of truth when in doubt), and since
`Bamboo.Email.get_address/1`'s explicit intent is to abstract the
internal representation of email addresses in case Bamboo changes how it
stores them:

> Gets just the email address from a normalized email address.
> Normalized email addresses are 2 item tuples {name, address}. This
gets the address part of the tuple. Use this instead of calling
elem(address, 1) so that if Bamboo changes how email addresses are
represented your code will still work

I think the correct change here is to remove the `String.t()` portion of
the typespec rather than update the code to handle that typespec. In
other words, I think we made a typo when introducing the typespec. So
this PR would be merged instead of #386.
@germsvel germsvel merged commit 4080bd6 into master Dec 24, 2020
@germsvel germsvel deleted the gv-fix-email-address-typespec branch December 24, 2020 14:15
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.

1 participant