Rumamge.Phoenix v1.0.0 Rummage.Phoenix.SortController
SortController
a controller helper in Rummage.Phoenix
which stores
helpers for Sort hook in Rummage
. This formats params before index
action into a format that is expected by the default Rummage.Ecto
’s sort
hook: Rummage.Ecto.Sort
Summary
Functions
This function formats params into rumamge
params, that are expected by
Rummage.Ecto
’s default sort hook
Functions
This function formats params into rumamge
params, that are expected by
Rummage.Ecto
’s default sort hook:
Examples
When rummage
passed is an empty Map
, it returns
and empty Map
:
iex> alias Rummage.Phoenix.SortController
iex> rummage = %{}
iex> SortController.rummage(rummage)
%{}
When rummage
passed is not an empty Map
, but
doesn’t have a "sort"
key, it returns
and empty Map
:
iex> alias Rummage.Phoenix.SortController
iex> rummage = %{"pizza" => "eat"}
iex> SortController.rummage(rummage)
%{}
When rummage
passed is not an empty Map
, but
the value corresponding to "sort"
key is an empty String
,
it returns and empty Map
:
iex> alias Rummage.Phoenix.SortController
iex> rummage = %{"sort" => ""}
iex> SortController.rummage(rummage)
%{}
When rummage
passed is not an empty Map
, but
the value corresponding to "sort"
key is a non-empty String
,
it decodes the value returns it:
iex> alias Rummage.Phoenix.SortController
iex> rummage = %{"sort" => "1"}
iex> SortController.rummage(rummage)
1
When rummage
passed is not an empty Map
, but
the value corresponding to "sort"
key is a Map
,
it returns the Map
itself:
iex> alias Rummage.Phoenix.SortController
iex> rummage = %{"sort" => %{"h" => "i"}}
iex> SortController.rummage(rummage)
%{"h" => "i"}