This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
907e330
commit b7bf1a8
Showing
4 changed files
with
105 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
defmodule HELL.Hector do | ||
|
||
alias HELL.Utils | ||
alias Helix.Server.Model.Server | ||
|
||
def caster(type, value) do | ||
case type do | ||
:server_id -> | ||
cast(Server.ID, value) | ||
_ -> | ||
has_id? = Utils.atom_contains?(value, "_id") | ||
|
||
if has_id? do | ||
raise "Unhandled id of type #{inspect type} for #{inspect value}" | ||
else | ||
Hector.std_caster(type, value) | ||
end | ||
end | ||
end | ||
|
||
def cast(module, value) do | ||
with {:ok, _} <- apply(module, :cast, [value]) do | ||
to_string(value) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters