Skip to content

Instantly share code, notes, and snippets.

@eduardonunesp
Last active June 13, 2016 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardonunesp/fea6b16a7c2984f74f4d14e5aa29bff6 to your computer and use it in GitHub Desktop.
Save eduardonunesp/fea6b16a7c2984f74f4d14e5aa29bff6 to your computer and use it in GitHub Desktop.
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
@eduardonunesp
Copy link
Author

== 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment