Skip to content

Instantly share code, notes, and snippets.

@KamilLelonek
Last active May 24, 2020 10:52
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 KamilLelonek/99a80299048075f93a100830e083518f to your computer and use it in GitHub Desktop.
Save KamilLelonek/99a80299048075f93a100830e083518f to your computer and use it in GitHub Desktop.
defmodule Pipelinex.Rating do
@enforce_keys ~w(author comment)a
defstruct @enforce_keys
def new(params), do: struct!(__MODULE__, params)
def encode(%__MODULE__{author: author, comment: comment}) do
%{
"author" => author,
"comment" => comment
}
end
end
defmodule Pipelinex.Video do
@enforce_keys ~w(title ratings)a
defstruct @enforce_keys
def new(params), do: struct!(__MODULE__, params)
def encode(%__MODULE__{title: title, ratings: ratings}),
do: %{"title" => title, "ratings" => ratings}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment