Brex v0.2.1 Brex.Rule.Struct View Source

Easily define your own struct based rules by using Brex.Rule.Struct.

It takes care of implementing Brex.Rule.Evaluable for you, as long as you define an evaluate/2 function receiving your struct and the value to evaluate.

Example

defmodule EqualRule do
  use Brex.Rule.Struct

  defstruct [:expected]

  def evaluate(%__MODULE__{expected: expected}, actual) do
    expected == actual
  end
end

Link to this section Summary

Link to this section Types