Localize.Script.Ecto.Type (Localize SQL v1.0.0)

Copy Markdown View Source

An Ecto.Type storing a script as its code in a text column.

A script is identified by its ISO 15924 code — :Latn, :Cyrl, :Hant — and that code is what is stored, in an ordinary text column. Values cast and load as the validated code atom, so an unknown script is rejected on the way in.

Schema

# in a migration
add :script, :string

# in a schema
field :script, Localize.Script.Ecto.Type

Casting

cast/1 accepts a code as an atom (:Latn) or a string ("Latn"), and validates it against Localize.validate_script/1.

Summary

Functions

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

Functions

embed_as(_)

Callback implementation for Ecto.Type.embed_as/1.

equal?(term1, term2)

Callback implementation for Ecto.Type.equal?/2.