Skip to content

Commit

Permalink
refactor Apartmentex.PrefixBuilder.build_prefix/1
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorganIO committed Mar 8, 2017
1 parent 71800b7 commit 42a2b1e
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/apartmentex/prefix_builder.ex
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
defmodule Apartmentex.PrefixBuilder do
@schema_prefix Application.get_env(:apartmentex, :schema_prefix) || "tenant_"

def build_prefix(tenant) when is_integer(tenant) do
@schema_prefix <> Integer.to_string(tenant)
end

def build_prefix(tenant) when is_binary(tenant) do
@schema_prefix <> tenant
end

def build_prefix(tenant) when is_integer(tenant), do: @schema_prefix <> Integer.to_string(tenant)
def build_prefix(tenant) when is_binary(tenant), do: @schema_prefix <> tenant
def build_prefix(tenant) do
cond do
is_binary(tenant.id) ->
@schema_prefix <> tenant.id
is_integer(tenant.id) ->
@schema_prefix <> Integer.to_string(tenant.id)
is_binary(tenant.id) -> build_prefix(tenant.id)
is_integer(tenant.id) -> build_prefix(tenant.id)
end
end
end

0 comments on commit 42a2b1e

Please sign in to comment.