# `ABSmartly.Matcher`
[🔗](https://github.com/absmartly/elixir-sdk/blob/v1.0.0/lib/absmartly/matcher.ex#L1)

Audience matcher for experiment targeting.

# `evaluate`
[🔗](https://github.com/absmartly/elixir-sdk/blob/v1.0.0/lib/absmartly/matcher.ex#L34)

Evaluate audience filter against attributes.

Returns:
- nil if filter is nil
- true if filter is empty map (matches all)
- result of filter evaluation otherwise
- nil when the filter value is not a list or map
- false for invalid filter structures (fail closed)

## Examples

    iex> evaluate(nil, %{})
    nil

    iex> evaluate(%{}, %{})
    true

    iex> evaluate(%{"filter" => [%{"value" => true}]}, %{})
    true

    iex> evaluate(%{"filter" => [%{"value" => false}]}, %{})
    false

# `evaluate_rules`
[🔗](https://github.com/absmartly/elixir-sdk/blob/v1.0.0/lib/absmartly/matcher.ex#L106)

Return the action of the first rule that matches `environment` and
`attributes`: `{:variant, variant}` for an `assign` rule, `{:split, fractions}`
for a `split` rule, or nil when no rule matches.

Mirrors the JavaScript SDK's `evaluateParsedRules` (src/matcher.ts): a rule
whose action is invalid (unknown type, non-integer variant, or percentages
that are not non-negative numbers summing to 100) is skipped. An
`environments` list, when present, must contain `environment` unless it is
empty. Absent conditions always match; otherwise they must be an object that
evaluates to true. Bounds checking the action is the caller's job.

# `parse_rules`
[🔗](https://github.com/absmartly/elixir-sdk/blob/v1.0.0/lib/absmartly/matcher.ex#L78)

Parse an experiment's `assignmentRules` JSON into its list of rules.

Returns nil when the value is absent, not valid JSON or not an object with a
`rules` list, in which case the experiment has no rules.

---

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