defmodule Matcher do def matches?(expected, actual) do with {:ok, _} <- match(expected, actual) do true else _ -> false end end def match(expected, actual) do Matcher.Protocol.match(expected, actual) end def equals(expected) do cond do is_map(expected) -> %Matcher.MapEquals{expected: expected} is_list(expected) -> %Matcher.ListEquals{expected: expected} :else -> %Matcher.Value{expected: expected} end end def embeds(expected) do %Matcher.MapEmbeds{expected: expected} end def in_any_order(expected) do %Matcher.ListInAnyOrder{expected: expected} end end