# `Bandera.Flag`

A named feature flag (a collection of gates) and its evaluation.

# `t`

```elixir
@type t() :: %Bandera.Flag{gates: [Bandera.Gate.t()], name: atom()}
```

# `enabled?`

```elixir
@spec enabled?(
  t(),
  keyword()
) :: boolean()
```

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

# `new`

```elixir
@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}]

---

*Consult [api-reference.md](api-reference.md) for complete listing*
