View Source Flint.Partial (Flint v0.2.0)
Can be use
d to create an Ecto.ParameterizedType
based on another Ecto.ParameterizedType
,
applying default parameters. You may supply any number of default parameters. This essentially provides a new
init/1
implementation for the type, supplying the default values, while not affecting any of the
other Ecto.ParameterizedType
callbacks.
You may still override the newly set defaults at the local level.
You may override any of the inherited Ecto.ParameterizedType
callbacks inherity from the extended module
in the case that you wish to customize the module further.
Examples
defmodule Category do
use Flint.Partial, extends: Ecto.Enum, values: [:folder, :file]
end
This will apply default values
to Ecto.Enum
when you supply a Cateogory
type
to an Ecto schema. You may still override the values if you supply the :values
option for the field.
Summary
Functions
A shorthand for creating a new module to represent a partial Ecto.ParameterizedType
. This is equivalent to
creating a new module with name module
and calling use Flint.Partial
and passing opts
.
Functions
A shorthand for creating a new module to represent a partial Ecto.ParameterizedType
. This is equivalent to
creating a new module with name module
and calling use Flint.Partial
and passing opts
.
Example
defpartial Vehicle, extends: Ecto.Enum, values: [:car, :motorcycle, :truck]