Filtrex v0.3.0 Filtrex.Utils.Encoder

Helper methods for implementing the Filtrex.Encoder protocol.

Summary

Macros

This macro allows a simple creation of encoders using a simple DSL

Macros

encoder(comparator, reverse_comparator, expression, values_function \\ {:&, [], [[{:&, [], [1]}]]})

This macro allows a simple creation of encoders using a simple DSL.

Example:

encoder "equals", "does not equal", "column = ?", &(&1)

In this example, a comparator and its reverse are passed in followed by an expression where “column” is substituted for the actual column name from the struct. The final argument is a function (which is not necessary in this case since it is the default value) that takes the raw value being passed in and returns the transformed value to be injected as a value into the fragment expression.