Skip to content

Instantly share code, notes, and snippets.

@willrax
Created July 8, 2016 14:42
Show Gist options
  • Save willrax/64da4ded1ef4042ab06696aaf1d37c95 to your computer and use it in GitHub Desktop.
Save willrax/64da4ded1ef4042ab06696aaf1d37c95 to your computer and use it in GitHub Desktop.
walnut_event-manager.ex
def site_checked(site = %{status: status}, status) do
payload = {:nochange, site, %{}}
GenServer.cast(__MODULE__, {:notify, {:site_checked, payload}})
end
def site_checked(site = %{status: new_status, reason: reason}, old_status) do
payload = {:change, site, %{from: old_status, to: new_status, reason: reason}}
GenServer.cast(__MODULE__, {:notify, {:site_checked, payload}})
end
def site_checked(site = %{status: new_status}, old_status) do
payload = {:change, site, %{from: old_status, to: new_status}}
GenServer.cast(__MODULE__, {:notify, {:site_checked, payload}})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment