PgRest.Utils (PgRest v0.1.0)

Copy Markdown View Source

Shared utility functions for PgRest modules.

Summary

Functions

Converts a string to an existing atom, passing atoms through unchanged.

Converts a string to an existing atom, returning nil if the atom does not exist.

Functions

safe_to_atom(name)

@spec safe_to_atom(atom()) :: atom()
@spec safe_to_atom(String.t()) :: atom()

Converts a string to an existing atom, passing atoms through unchanged.

Raises ArgumentError if the atom does not already exist.

safe_to_existing_atom(name)

@spec safe_to_existing_atom(atom()) :: atom()
@spec safe_to_existing_atom(String.t()) :: atom() | nil

Converts a string to an existing atom, returning nil if the atom does not exist.

Passes atoms through unchanged.