Skip to content

Commit

Permalink
fix: conditionally compile Decimal block
Browse files Browse the repository at this point in the history
  • Loading branch information
tlux committed Jul 15, 2020
1 parent 3e7d8f2 commit 7e63658
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/file_size/ecto/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ defmodule FileSize.Ecto.Utils do

alias FileSize.Units

@spec assert_value(value) :: {:ok, value} | :error
when value: number | Decimal.t()
def assert_value(%Decimal{} = value), do: {:ok, value}
if Code.ensure_loaded?(Decimal) do
@spec assert_value(value) :: {:ok, value} | :error
when value: number | Decimal.t()
def assert_value(%Decimal{} = value), do: {:ok, value}
else
@spec assert_value(value) :: {:ok, value} | :error when value: number
end

def assert_value(value) when is_number(value), do: {:ok, value}
def assert_value(_), do: :error

Expand Down

0 comments on commit 7e63658

Please sign in to comment.