View Source CozyParams.Schema.AST (cozy_params v2.1.0)
Process the AST of cozy_params
.
Link to this section Summary
Functions
Make sure that the AST is always a block.
Transform cozy_params
supported AST to Ecto supported AST.
Extract metadata from AST.
Transpile shortcuts of embeds_one
and embeds_many
.
Validate if the block meets cozy_params
's requirements.
Link to this section Functions
Make sure that the AST is always a block.
Transform cozy_params
supported AST to Ecto supported AST.
Currently, this function will:
- drop options which are supported by
cozy_params
only. Or, Ecto will report invalid option errors.
Extract metadata from AST.
Transpile shortcuts of embeds_one
and embeds_many
.
cozy_params
will transpile code like following one:
embeds_one :address, required: true do
field :latitude, :float, required: true
field :longtitude, :float, required: true
end
to Ecto supported code:
defmodule Address do
use CozyParams.Schema
schema do
field :latitude, :float, required: true
field :longtitude, :float, required: true
end
end
embeds_one :address, Address
Validate if the block meets cozy_params
's requirements.
Although cozy_params
try its best to emulate the API of Ecto.Schema
, but it
doesn't mean that every API of Ecto.Schema
is supported by cozy_params
.
Because of that, cozy_params
validates the calls before proceeding.