Move implementation to own file
Prefactoring, from TDDAYMI to imperative shell. In the next step we need the implementation from the functional core in the imperative shell, to pass in the environment variable.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
defmodule FunCore.BasicSignupWhitelist do
|
||||
def normalize(email) do
|
||||
email |> String.trim() |> String.downcase()
|
||||
end
|
||||
|
||||
def addresses_as_list(addresses_str) do
|
||||
addresses_str
|
||||
|> String.split(",")
|
||||
|> Enum.map(&normalize/1)
|
||||
end
|
||||
|
||||
def mail_whitelisted_fun(signups_allowed, email_received) do
|
||||
case signups_allowed do
|
||||
nil -> false
|
||||
"*" -> true
|
||||
list_str -> normalize(email_received) in addresses_as_list(list_str)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user