From 473cb50ccc18a7601c489cf977e606bc5b892f92 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Sun, 13 Sep 2020 22:29:47 +0100 Subject: [PATCH] update all instances of "@behaviour Ecto.Type" to "use Ecto.Type" https://github.com/dwyl/fields/issues/76#issuecomment-691727952 --- lib/address.ex | 3 +-- lib/address_encrypted.ex | 3 +-- lib/aes.ex | 3 ++- lib/description_plaintext_unlimited.ex | 2 +- lib/email_encrypted.ex | 3 +-- lib/email_hash.ex | 3 +-- lib/email_plaintext.ex | 3 +-- lib/encrypted.ex | 3 +-- lib/hash.ex | 3 +-- lib/html-body.ex | 2 +- lib/ip_address_encrypted.ex | 3 +-- lib/ip_address_hash.ex | 3 +-- lib/ip_address_plaintext.ex | 3 +-- lib/name.ex | 3 +-- lib/password.ex | 3 +-- lib/phone_number.ex | 3 +-- lib/phone_number_encrypted.ex | 3 +-- lib/postcode.ex | 3 +-- lib/postcode_encrypted.ex | 3 +-- lib/url.ex | 3 +-- lib/url_encrypted.ex | 3 +-- 21 files changed, 22 insertions(+), 39 deletions(-) diff --git a/lib/address.ex b/lib/address.ex index 7f81770..7edfb02 100644 --- a/lib/address.ex +++ b/lib/address.ex @@ -13,8 +13,7 @@ defmodule Fields.Address do ``` """ alias Fields.Validate - - @behaviour Ecto.Type + use Ecto.Type def type, do: :string diff --git a/lib/address_encrypted.ex b/lib/address_encrypted.ex index e04644d..35bf5f2 100644 --- a/lib/address_encrypted.ex +++ b/lib/address_encrypted.ex @@ -9,8 +9,7 @@ defmodule Fields.AddressEncrypted do end """ alias Fields.{Address, Encrypted} - - @behaviour Ecto.Type + use Ecto.Type def type, do: :binary diff --git a/lib/aes.ex b/lib/aes.ex index cb9da37..ac2e06d 100644 --- a/lib/aes.ex +++ b/lib/aes.ex @@ -13,8 +13,9 @@ defmodule Fields.AES do |> String.replace("'", "") #  split the CSV list of keys |> String.split(",") + |> IO.inspect() # decode the keys - |> Enum.map(fn key -> :base64.decode(key) end) + |> Enum.map(fn key -> :base64.decode(to_string(key)) end) @doc """ Encrypt Using AES Galois/Counter Mode (GCM) https://en.wikipedia.org/wiki/Galois/Counter_Mode diff --git a/lib/description_plaintext_unlimited.ex b/lib/description_plaintext_unlimited.ex index 8c77a02..46bf285 100644 --- a/lib/description_plaintext_unlimited.ex +++ b/lib/description_plaintext_unlimited.ex @@ -9,7 +9,7 @@ defmodule Fields.DescriptionPlaintextUnlimited do field(:description, Fields.DescriptionPlaintextUnlimited) end """ - @behaviour Ecto.Type + use Ecto.Type def type, do: :string diff --git a/lib/email_encrypted.ex b/lib/email_encrypted.ex index e966808..a3defb2 100644 --- a/lib/email_encrypted.ex +++ b/lib/email_encrypted.ex @@ -9,8 +9,7 @@ defmodule Fields.EmailEncrypted do end """ alias Fields.{EmailPlaintext, Encrypted} - - @behaviour Ecto.Type + use Ecto.Type def type, do: :binary diff --git a/lib/email_hash.ex b/lib/email_hash.ex index 453c476..ebac17e 100644 --- a/lib/email_hash.ex +++ b/lib/email_hash.ex @@ -12,8 +12,7 @@ defmodule Fields.EmailHash do end """ alias Fields.{EmailPlaintext, Hash} - - @behaviour Ecto.Type + use Ecto.Type def type, do: :binary diff --git a/lib/email_plaintext.ex b/lib/email_plaintext.ex index 2ca3514..322eb37 100644 --- a/lib/email_plaintext.ex +++ b/lib/email_plaintext.ex @@ -11,8 +11,7 @@ defmodule Fields.EmailPlaintext do end """ alias Fields.Validate - - @behaviour Ecto.Type + use Ecto.Type def type, do: :string diff --git a/lib/encrypted.ex b/lib/encrypted.ex index 9fdfd6f..a0ff8a0 100644 --- a/lib/encrypted.ex +++ b/lib/encrypted.ex @@ -10,8 +10,7 @@ defmodule Fields.Encrypted do end """ alias Fields.AES - - @behaviour Ecto.Type + use Ecto.Type def type, do: :binary def cast(value) do diff --git a/lib/hash.ex b/lib/hash.ex index 5e5e5df..2e448a1 100644 --- a/lib/hash.ex +++ b/lib/hash.ex @@ -9,8 +9,7 @@ defmodule Fields.Hash do field(:digest, Fields.Hash) end """ - @behaviour Ecto.Type - + use Ecto.Type alias Fields.Helpers def type, do: :binary diff --git a/lib/html-body.ex b/lib/html-body.ex index 35b1aeb..4cc9a97 100644 --- a/lib/html-body.ex +++ b/lib/html-body.ex @@ -10,7 +10,7 @@ defmodule Fields.HtmlBody do field(:body, Fields.HtmlBody) end """ - @behaviour Ecto.Type + use Ecto.Type def type, do: :string diff --git a/lib/ip_address_encrypted.ex b/lib/ip_address_encrypted.ex index 3e9c345..60bfffa 100644 --- a/lib/ip_address_encrypted.ex +++ b/lib/ip_address_encrypted.ex @@ -9,8 +9,7 @@ defmodule Fields.IpAddressEncrypted do end """ alias Fields.{IpAddressPlaintext, Encrypted} - - @behaviour Ecto.Type + use Ecto.Type def type, do: :binary diff --git a/lib/ip_address_hash.ex b/lib/ip_address_hash.ex index 16370fc..29f1fa1 100644 --- a/lib/ip_address_hash.ex +++ b/lib/ip_address_hash.ex @@ -10,8 +10,7 @@ defmodule Fields.IpAddressHash do end """ alias Fields.{IpAddressPlaintext, Hash} - - @behaviour Ecto.Type + use Ecto.Type def type, do: :binary diff --git a/lib/ip_address_plaintext.ex b/lib/ip_address_plaintext.ex index ddb5de4..0ff4a70 100644 --- a/lib/ip_address_plaintext.ex +++ b/lib/ip_address_plaintext.ex @@ -9,8 +9,7 @@ defmodule Fields.IpAddressPlaintext do end """ alias Fields.Validate - - @behaviour Ecto.Type + use Ecto.Type def type, do: :string diff --git a/lib/name.ex b/lib/name.ex index 394bf98..049d8db 100644 --- a/lib/name.ex +++ b/lib/name.ex @@ -13,8 +13,7 @@ defmodule Fields.Name do ``` """ alias Fields.{Validate, Encrypted} - - @behaviour Ecto.Type + use Ecto.Type def type, do: :binary diff --git a/lib/password.ex b/lib/password.ex index eb000a5..187dce2 100644 --- a/lib/password.ex +++ b/lib/password.ex @@ -10,8 +10,7 @@ defmodule Fields.Password do field(:password, Fields.Password) end """ - @behaviour Ecto.Type - + use Ecto.Type alias Fields.Helpers def type, do: :binary diff --git a/lib/phone_number.ex b/lib/phone_number.ex index ed5a01b..ff3b598 100644 --- a/lib/phone_number.ex +++ b/lib/phone_number.ex @@ -11,8 +11,7 @@ defmodule Fields.PhoneNumber do end """ alias Fields.Validate - - @behaviour Ecto.Type + use Ecto.Type def type, do: :string diff --git a/lib/phone_number_encrypted.ex b/lib/phone_number_encrypted.ex index 10de46b..6cc039a 100644 --- a/lib/phone_number_encrypted.ex +++ b/lib/phone_number_encrypted.ex @@ -9,8 +9,7 @@ defmodule Fields.PhoneNumberEncrypted do end """ alias Fields.{PhoneNumber, Encrypted} - - @behaviour Ecto.Type + use Ecto.Type def type, do: :binary diff --git a/lib/postcode.ex b/lib/postcode.ex index b933d0b..a568e69 100644 --- a/lib/postcode.ex +++ b/lib/postcode.ex @@ -10,8 +10,7 @@ defmodule Fields.Postcode do end """ alias Fields.Validate - - @behaviour Ecto.Type + use Ecto.Type def type, do: :string diff --git a/lib/postcode_encrypted.ex b/lib/postcode_encrypted.ex index ecd84d9..de99aff 100644 --- a/lib/postcode_encrypted.ex +++ b/lib/postcode_encrypted.ex @@ -11,8 +11,7 @@ defmodule Fields.PostcodeEncrypted do end """ alias Fields.{Postcode, Encrypted} - - @behaviour Ecto.Type + use Ecto.Type def type, do: :binary diff --git a/lib/url.ex b/lib/url.ex index 8953eda..d02ac11 100644 --- a/lib/url.ex +++ b/lib/url.ex @@ -10,8 +10,7 @@ defmodule Fields.Url do end """ alias Fields.Validate - - @behaviour Ecto.Type + use Ecto.Type def type, do: :string diff --git a/lib/url_encrypted.ex b/lib/url_encrypted.ex index 77a594d..7946966 100644 --- a/lib/url_encrypted.ex +++ b/lib/url_encrypted.ex @@ -12,8 +12,7 @@ defmodule Fields.UrlEncrypted do ``` """ alias Fields.{Validate, Encrypted} - - @behaviour Ecto.Type + use Ecto.Type def type, do: :binary