View Source OnePiece.Commanded.ValueObject (OnePiece.Commanded v0.19.0)

Defines "Value Object" modules.

Link to this section Summary

Functions

Converts the module into an Ecto.Schema and add factory functions to create structs.

Link to this section Functions

Link to this macro

__using__(opts \\ [])

View Source (macro)
@spec __using__(opts :: []) :: any()

Converts the module into an Ecto.Schema and add factory functions to create structs.

using

Using

derives

Derives

usage

Usage

defmodule MyValueObject do
  use OnePiece.Commanded.ValueObject

  embedded_schema do
    field :title, :string
    # ...
  end
end

{:ok, my_value} = MyValueObject.new(%{title: "Hello, World!"})