Last active
June 13, 2016 02:06
-
-
Save eduardonunesp/fea6b16a7c2984f74f4d14e5aa29bff6 to your computer and use it in GitHub Desktop.
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
defmodule Pinger.Destiny do | |
@moduledoc """ | |
Module responsible for the destiny struct, | |
which is the name and address of the ping target | |
""" | |
defstruct name: nil, | |
address: nil, | |
active: false | |
def new(name, address, active \\ true) when is_binary(name) and is_binary(address) do | |
%__MODULE__{ | |
name: name, | |
address: address, | |
active: active | |
} | |
end | |
def mark_inactive(%__MODULE__{} = dest) do | |
%{ dest | active: false} | |
end | |
def mark_active(%__MODULE__{} = dest) do | |
%{ dest | active: true} | |
end | |
def update_name(%__MODULE__{} = dest, name) when is_binary(name) do | |
%{ dest | name: name} | |
end | |
def update_address(%__MODULE__{} = dest, address) when is_binary(address) do | |
%{ dest | address: address} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
== Compilation error on file lib/Pinger/Destiny.ex ==
** (SyntaxError) lib/Pinger/Destiny.ex:17: syntax error before: is_http
(elixir) lib/kernel/parallel_compiler.ex:116: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1