Created
July 22, 2016 01:44
-
-
Save mikebaldry/5cf02da7fad2e64c565832d4ebdbee73 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
defmodule TestApp.Serializer do | |
defmacro __using__(_) do | |
quote do | |
defimpl Msgpax.Packer, for: __MODULE__ do | |
def transform(struct) do | |
type = String.replace_prefix(to_string(__MODULE__), "Elixir.Msgpax.Packer.TestApp.Data.", "") | |
Msgpax.Packer.Map.transform(Map.merge(Map.from_struct(struct), %{"__type" => type})) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment