”Use“ and some metaprograming to refactor behaviours implimentation

This commit is contained in:
2024-03-07 18:33:38 -05:00
parent 368225f331
commit 1a9d6758fd
23 changed files with 106 additions and 438 deletions

View File

@@ -3,23 +3,15 @@ defmodule IbanEx.Country.FR do
France IBAN parsing rules
"""
alias IbanEx.Iban
@behaviour IbanEx.Country.Template
@size 27
@rule ~r/^(?<bank_code>[0-9]{5})(?<branch_code>[0-9]{5})(?<account_number>[0-9A-Z]{11})(?<national_check>[0-9]{2})$/i
@spec size() :: 27
def size(), do: @size
use IbanEx.Country.Template
@spec rule() :: Regex.t()
def rule(), do: @rule
@spec to_s(Iban.t()) :: binary()
@spec to_s(Iban.t(), binary()) :: binary()
def to_s(
@impl IbanEx.Country.Template
@spec to_string(Iban.t()) :: binary()
@spec to_string(Iban.t(), binary()) :: binary()
def to_string(
%Iban{
country_code: country_code,
check_digits: check_digits,