Bandera. Flag
(bandera v0.1.0)
Copy Markdown
A named feature flag (a collection of gates) and its evaluation.
Summary
Functions
Evaluates the flag, returning whether it is enabled for the given input.
Builds a flag named name from a (possibly empty) list of gates.
Types
@type t() :: %Bandera.Flag{gates: [Bandera.Gate.t()], name: atom()}
Functions
Evaluates the flag, returning whether it is enabled for the given input.
With no :for, only boolean and percentage-of-time gates are consulted. With
for: item, actor gates are checked first, then group gates, then the boolean
and percentage-of-actors gates. A flag with no gates is disabled.
Examples
iex> Bandera.Flag.enabled?(Bandera.Flag.new(:f, [Bandera.Gate.new(:boolean, true)]))
true
iex> Bandera.Flag.enabled?(Bandera.Flag.new(:f))
false
iex> Bandera.Flag.enabled?(Bandera.Flag.new(:f, [Bandera.Gate.new(:actor, "u1", true)]), for: "u1")
true
@spec new(atom(), [Bandera.Gate.t()]) :: t()
Builds a flag named name from a (possibly empty) list of gates.
Examples
iex> Bandera.Flag.new(:my_flag)
%Bandera.Flag{name: :my_flag, gates: []}
iex> flag = Bandera.Flag.new(:my_flag, [Bandera.Gate.new(:boolean, true)])
iex> flag.gates
[%Bandera.Gate{type: :boolean, for: nil, enabled: true}]