kamillelonek / exnumerator Goto Github PK
View Code? Open in Web Editor NEWEnumerable type in Elixir
Enumerable type in Elixir
I am getting this because your package have ex_doc
in prod
as you can see and my dependency is only for dev
* ex_doc (Hex package)
the :only option for dependency ex_doc
> In mix.exs:
{:ex_doc, ">= 0.0.0", [env: :prod, repo: "hexpm", hex: "ex_doc", only: :dev, runtime: false, manager: :mix]}
does not match the :only option calculated for
> In deps/exnumerator/mix.exs:
{:ex_doc, ">= 0.0.0", [env: :prod, hex: "ex_doc", repo: "hexpm", optional: false]}
Remove the :only restriction from your dep
** (Mix) Can't continue due to errors on dependencies
I understand what you are doing with mix.exs
and deps
but it is failing so
warning: function embed_as/1 required by behaviour Ecto.Type is not implemented
I'm trying exnumerator now, and found that only atom type is allowed for the values which string doesn't.
Since it won't harm the functionality, it'd be better using with string not to consume erlang's atom limitation.
While the developers feel comfortable with atom logically, which the name itself represent their values are atomic, the DB will likely have its values with string physically. And even we no more need to use :erlang.atom_to_binary/2
, right?
I'm working with a legacy database that has a status column with single-character values. I would prefer to represent this with an enum so I can use descriptive words as values.
defmodule MyType do
use Exnumerator, values: [active: "A", inactive: "I", pending: "P"]
end
I've implemented this myself as:
defmodule Status do
@behaviour Ecto.Type
@values [active: "A", pending: "P", inactive: "I"]
def type, do: :string
def values, do: @values
for {name, value} <- @values do
def cast(unquote(name)), do: {:ok, unquote(name)}
def cast(unquote(value)), do: {:ok, unquote(name)}
def load(unquote(value)), do: {:ok, unquote(name)}
def dump(unquote(name)), do: {:ok, unquote(value)}
def dump(unquote(value)), do: {:ok, unquote(value)}
end
def cast(_), do: :error
def load(_), do: :error
def dump(_), do: :error
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.