Filtrex v0.4.3 Filtrex.Type.Config

This configuration struct is for passing options at the top-level (e.g. Filtrex.parse/2) in a list. See defconfig/1 for a more specific example.

Struct keys:

  • type: the corresponding condition module with this type (e.g. :text = Filtrex.Condition.Text)
  • keys: the allowed keys for this configuration
  • options: the configuration options to be passed to the condition

Summary

Functions

Returns whether the passed key is listed in any of the configurations

Returns the configuration for the specified key

Narrows the list of configurations to only the specified type

Returns the specific options of a configuration based on the key

Convert a list of mixed atoms and/or strings to a list of strings

Macros

Allows easy creation of a configuration list

Types

t :: Filtrex.Type.Config

Functions

allowed?(configs, key)

Returns whether the passed key is listed in any of the configurations

config(configs, key)

Returns the configuration for the specified key

configs_for_type(configs, type)

Narrows the list of configurations to only the specified type

options(configs, key)

Returns the specific options of a configuration based on the key

to_strings(keys, strings \\ [])

Convert a list of mixed atoms and/or strings to a list of strings

Macros

boolean(key_or_keys, opts \\ [])

Generate a config struct for Filtrex.Condition.Boolean

date(key_or_keys, opts \\ [])

Generate a config struct for Filtrex.Condition.Date

datetime(key_or_keys, opts \\ [])

Generate a config struct for Filtrex.Condition.DateTime

defconfig(block)

Allows easy creation of a configuration list:

iex> import Filtrex.Type.Config
iex>
iex> defconfig do
iex>   # Single key can be passed
iex>   number :rating, allow_decimal: true
iex>
iex>   # Multiple keys
iex>   text [:title, :description]
iex>
iex>   # String key can be passed
iex>   date "posted", format: "{ISOz}"
iex> end
[
  %Filtrex.Type.Config{keys: ["rating"], options: %{allow_decimal: true}, type: :number},
  %Filtrex.Type.Config{keys: ["title", "description"], options: %{}, type: :text},
  %Filtrex.Type.Config{keys: ["posted"], options: %{format: "{ISOz}"}, type: :date}
]
number(key_or_keys, opts \\ [])

Generate a config struct for Filtrex.Condition.Number

text(key_or_keys, opts \\ [])

Generate a config struct for Filtrex.Condition.Text