WorkerLib.Serify.Model (serify v0.1.0)

Copy Markdown View Source

Ecto-style schema for Serify models.

Usage:

defmodule MyApp.User do
  use WorkerLib.Serify.Model

  serify_field :user_id, :u64
  serify_field :name,    :string
  serify_field :email,   :string, key: "email_addr"
  serify_field :address, :struct, module: Address
  serify_field :labels,  :map, of: :string
  serify_field :scores,  :map, of: {:struct, GameScore}
end

This generates:

  • to_field_map/1 (struct → map)
  • from_field_map/1 (map → struct)

Summary

Functions

def_serify_functions(fields, mod)

serify_field(name, type, opts \\ [])

(macro)