Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Last active August 29, 2015 14:15
Show Gist options
  • Save guilleiguaran/f78ea9de1816c4f748f5 to your computer and use it in GitHub Desktop.
Save guilleiguaran/f78ea9de1816c4f748f5 to your computer and use it in GitHub Desktop.
defmodule Comision do
defstruct estado: nil
def liquidar(%Comision{} = c) do
%{c | estado: :liquidada}
end
def anular(%Comision{estado: :liquidada} = c) do
%{c | estado: :anulada}
end
def aprobar(%Comision{estado: :liquidada} = c) do
%{c | estado: :aprobada}
end
def facturar(%Comision{estado: :aprobada} = c) do
%{c | estado: :facturada}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment