Created
October 17, 2014 13:57
-
-
Save mschae/56e7ad574405ca53f30a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
for event <- [:before_save, :before_update, :before_delete] do | |
defmacro unquote(event)(function) do | |
quote bind_quoted: [event: event] do | |
Ecto.Model.Callbacks.register_callback(__MODULE__, event, unquote(function)) | |
def __callbacks__(:before_save), do: Keyword.get_values(@ecto_callbacks, :before_save) | |
end | |
end | |
end |
chrismccord
commented
Oct 17, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment