A bitmask implementation for elixir, with optional Ecto support.
defmodule MyBitmask do
use Bitmask, [
:flag_1,
:flag_2,
:flag_3,
:flag_4,
]
end
iex> bitmask = MyBitmask.atom_flags_to_bitmask([:flag_1, :flag_3])
%MyBitmask{bitmask: 5, flags: [:flag_1, :flag_3]}
iex> MyBitmask.has_flag(bitmask, :flag_1])
true
defmodule SomeEctoSchema do
use Ecto.Schema
schema "bitmasks" do
field :my_bitmask, MyBitmask
end
end
See the docs for more info. Issues / PRs / Feedback welcome.