Steve and his crew have already loaded the boat and untied the ropes from the dock. As their boat putters out of the marina before the sunrises, a stiff morning breeze blows over the deck. The crew…
An Elixir behaviour is just a list of functions. A module that declares that it implements a particular behaviour must implement all of these functions.
I would say that behaviours are kind of interfaces from the OOP world.
So if you want to use custom types then you should implement all of these 4 functions: type
, cast
, load
and dump
. Otherwise, Elixir will throw a compilation warning.
@behaviour
declares that Arc.Ecto.Definition
implements Ecto.Type
and then defines necessary functions.
Then you can use Arc’s custom type in your app:
That’s all for today.
Thank you for reading this post!
Matchbox Quotes Day 36 [2018–02–03]. “Oath” is published by Tre L. Loadholt in Scene & Heard (SNH).
One of the many problems that plenty of low-income neighborhoods have faced is gentrification. Through time and time again, many low-income families are getting evicted due to rent exponentially…
Given how pervasively political, cultural, educational, and religious institutions are built on a foundation of stereotypes and binary assumptions, it is easy to understand why people find the…