Multilingual.View (multilingual v0.1.2)
Summary
Functions
Fetches a key from the private View data in the connection and raises an error is not view is found.
Fetches a key from the private View data in the connection or returns nil if the view is not found.
Functions
Link to this function
fetch_key(conn, key)
Fetches a key from the private View data in the connection and raises an error is not view is found.
Examples
iex> view = %Multilingual.View{locale: "en", path: "/about"}
...> conn = Plug.Conn.put_private(%Plug.Conn{}, :multilingual, view)
...> Multilingual.View.fetch_key(conn, :path)
"/about"
iex> view = %Multilingual.View{locale: "en", path: "/about"}
...> conn = Plug.Conn.put_private(%Plug.Conn{}, :multilingual, view)
...> Multilingual.View.fetch_key(conn, :bad_key)
** (FunctionClauseError) no function clause matching in Multilingual.View.fetch_key/2
Link to this function
get_key(conn, key)
Fetches a key from the private View data in the connection or returns nil if the view is not found.
Raises an error if an erroneous key is requested.
Examples
iex> view = %Multilingual.View{locale: "en", path: "/about"}
...> conn = Plug.Conn.put_private(%Plug.Conn{}, :multilingual, view)
...> Multilingual.View.get_key(conn, :path)
"/about"
iex> Multilingual.View.get_key(%Plug.Conn{}, :path)
nil
iex> view = %Multilingual.View{locale: "en", path: "/about"}
...> conn = Plug.Conn.put_private(%Plug.Conn{}, :multilingual, view)
...> Multilingual.View.get_key(conn, :bad_key)
** (FunctionClauseError) no function clause matching in Multilingual.View.get_key/2