It would be quite convenient to be able to wrap up true/false into something that returns an exception if on false (maybe if on true via configurable option) or else passes the input value unaltered. An example:
# Assuming test_bool is a something like `safe` is in usage:
request_ip
|> get_client_ip(params)
|> Geoip.lookup_ip() |> normalize # normalize takes a tagged-tuple and converts it to an ErlangError or unwraps an :ok tuple
~> bool_test(should_search?/1).(parse_exclusion_zone(params)) # Here
~> build_search_query(%SearchQuery{}, params)
~> NGSearch.search() |> normalize
~> Analytics.track(client_ip, "api", "search_results")
~> (&json(conn, &1)).()
|> ensure!
Although with macro work could clean it up (and could clean up others, like safe as well).
Basically just return an ErlangError (preferably saying what failed, by saying the passed in 'should_search?/1' failed its test), else it returns the prior passed in value.
It would be quite convenient to be able to wrap up true/false into something that returns an exception if on false (maybe if on true via configurable option) or else passes the input value unaltered. An example:
Although with macro work could clean it up (and could clean up others, like
safeas well).Basically just return an ErlangError (preferably saying what failed, by saying the passed in 'should_search?/1' failed its test), else it returns the prior passed in value.