This is a feature for v0.3.x, will use a totally different DSL.
the type option is quite useful for generating documents.
custom Type can be defined like this:
defmodule Maru.Types.Date do
use Maru.Type
def arguments do
[:format]
end
def serialize(output, %{format: "m/d/Y"}) do
...
end
def serialize(output, %{format: "Y-m-d"}) do
...
end
end
expose :age, type: Integer
expose :name, type: fn(instance, _options) ->
"#{instance.firstname} #{instance.lastname}"
end |> String
expose :image, type: fn(instance, _options) ->
File.read!(instance.image_path)
end |> Base64
expose :data, type: Data, format: "m/d/Y"
expose :posts, type: List[PostEntity]
This is a feature for
v0.3.x, will use a totally different DSL.the
typeoption is quite useful for generating documents.custom Type can be defined like this: